about summary refs log tree commit diff
path: root/nixpkgs/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-fixup-hook.sh
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2022-03-15 10:36:38 +0000
committerAlyssa Ross <hi@alyssa.is>2022-03-16 11:37:19 +0000
commitd435710923ac6e6f9fc155534800745004f2ce93 (patch)
tree386f9401476f96bdc6ec25173a090198942b5d5b /nixpkgs/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-fixup-hook.sh
parentc725f0011e91ae49d351b981690eb66b862b6104 (diff)
parent3239fd2b8f728106491154b44625662e10259af2 (diff)
downloadnixlib-d435710923ac6e6f9fc155534800745004f2ce93.tar
nixlib-d435710923ac6e6f9fc155534800745004f2ce93.tar.gz
nixlib-d435710923ac6e6f9fc155534800745004f2ce93.tar.bz2
nixlib-d435710923ac6e6f9fc155534800745004f2ce93.tar.lz
nixlib-d435710923ac6e6f9fc155534800745004f2ce93.tar.xz
nixlib-d435710923ac6e6f9fc155534800745004f2ce93.tar.zst
nixlib-d435710923ac6e6f9fc155534800745004f2ce93.zip
Merge commit '3239fd2b8f728106491154b44625662e10259af2'
Conflicts:
	nixpkgs/pkgs/applications/window-managers/sway/default.nix
Diffstat (limited to 'nixpkgs/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-fixup-hook.sh')
-rw-r--r--nixpkgs/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-fixup-hook.sh42
1 files changed, 42 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-fixup-hook.sh b/nixpkgs/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-fixup-hook.sh
new file mode 100644
index 000000000000..f8bbb7b1805b
--- /dev/null
+++ b/nixpkgs/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-fixup-hook.sh
@@ -0,0 +1,42 @@
+declare -a makeWrapperArgs gappsWrapperArgs
+
+# First argument is the executable you want to wrap,
+# the second is the destination for the wrapper.
+wrapDotnetProgram() {
+    makeWrapper "$1" "$2" \
+        --set "DOTNET_ROOT" "@dotnetRuntime@" \
+        --suffix "LD_LIBRARY_PATH" : "@runtimeDeps@" \
+        "${gappsWrapperArgs[@]}" \
+        "${makeWrapperArgs[@]}"
+
+    echo "Installed wrapper to: "$2""
+}
+
+dotnetFixupHook() {
+    echo "Executing dotnetFixupPhase"
+
+    if [ "${executables-}" ]; then
+        for executable in ${executables[@]}; do
+            execPath="$out/lib/${pname-}/$executable"
+
+            if [[ -f "$execPath" && -x "$execPath" ]]; then
+                wrapDotnetProgram "$execPath" "$out/bin/$(basename "$executable")"
+            else
+                echo "Specified binary \"$executable\" is either not an executable, or does not exist!"
+                exit 1
+            fi
+        done
+    else
+        for executable in $out/lib/${pname-}/*; do
+            if [[ -f "$executable" && -x "$executable" && "$executable" != *"dll"* ]]; then
+                wrapDotnetProgram "$executable" "$out/bin/$(basename "$executable")"
+            fi
+        done
+    fi
+
+    echo "Finished dotnetFixupPhase"
+}
+
+if [[ -z "${dontDotnetFixup-}" ]]; then
+    preFixupPhases+=" dotnetFixupHook"
+fi