From fcbd42974214dacba9b283166fe8ead0a04644a2 Mon Sep 17 00:00:00 2001 From: IvarWithoutBones Date: Wed, 12 Jan 2022 00:03:02 +0100 Subject: [PATCH] buildDotnetModule: wrap executables in preFixup Not doing this used to break wrapGAppsHook as gappsWrapperArgs is set in preFixup, but it was used in installPhase --- doc/languages-frameworks/dotnet.section.md | 2 +- .../build-dotnet-module/default.nix | 34 ++++++++++--------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/doc/languages-frameworks/dotnet.section.md b/doc/languages-frameworks/dotnet.section.md index 88e1a0b2959..f7af28a1677 100644 --- a/doc/languages-frameworks/dotnet.section.md +++ b/doc/languages-frameworks/dotnet.section.md @@ -84,7 +84,7 @@ To package Dotnet applications, you can use `buildDotnetModule`. This has simila ``` -* `executables` is used to specify which executables get wrapped to `$out/bin`, relative to `$out/lib/$pname`. If this is unset, all executables generated will get installed. If you do not want to install any, set this to `[]`. +* `executables` is used to specify which executables get wrapped to `$out/bin`, relative to `$out/lib/$pname`. If this is unset, all executables generated will get installed. If you do not want to install any, set this to `[]`. This gets done in the `preFixup` phase. * `runtimeDeps` is used to wrap libraries into `LD_LIBRARY_PATH`. This is how dotnet usually handles runtime dependencies. * `buildType` is used to change the type of build. Possible values are `Release`, `Debug`, etc. By default, this is set to `Release`. * `dotnet-sdk` is useful in cases where you need to change what dotnet SDK is being used. diff --git a/pkgs/build-support/build-dotnet-module/default.nix b/pkgs/build-support/build-dotnet-module/default.nix index 0a5b17a4a36..49a61f4e5d6 100644 --- a/pkgs/build-support/build-dotnet-module/default.nix +++ b/pkgs/build-support/build-dotnet-module/default.nix @@ -224,7 +224,7 @@ let "''${dotnetInstallFlags[@]}" \ "''${dotnetFlags[@]}" done - '' + (lib.optionalString packNupkg '' + '' + lib.optionalString packNupkg '' for project in ''${projectFile[@]}; do dotnet pack "$project" \ -p:ContinuousIntegrationBuild=true \ @@ -235,16 +235,24 @@ let "''${dotnetPackFlags[@]}" \ "''${dotnetFlags[@]}" done - '') + (if executables != null then '' - for executable in $executables; do + '' + '' + runHook postInstall + ''; + + preFixup = '' + _wrapDotnetProgram() { + makeWrapper "$1" "$out/bin/$(basename "$executable")" \ + --set DOTNET_ROOT "${dotnet-runtime}" \ + --suffix LD_LIBRARY_PATH : "${lib.makeLibraryPath runtimeDeps}" \ + "''${gappsWrapperArgs[@]}" \ + "''${makeWrapperArgs[@]}" + } + '' + (if executables != null then '' + for executable in ''${executables[@]}; do execPath="$out/lib/${args.pname}/$executable" if [[ -f "$execPath" && -x "$execPath" ]]; then - makeWrapper "$execPath" "$out/bin/$(basename "$executable")" \ - --set DOTNET_ROOT "${dotnet-runtime}" \ - --suffix LD_LIBRARY_PATH : "${lib.makeLibraryPath runtimeDeps}" \ - "''${gappsWrapperArgs[@]}" \ - "''${makeWrapperArgs[@]}" + _wrapDotnetProgram $execPath else echo "Specified binary \"$executable\" is either not an executable, or does not exist!" exit 1 @@ -253,16 +261,10 @@ let '' else '' for executable in $out/lib/${args.pname}/*; do if [[ -f "$executable" && -x "$executable" && "$executable" != *"dll"* ]]; then - makeWrapper "$executable" "$out/bin/$(basename "$executable")" \ - --set DOTNET_ROOT "${dotnet-runtime}" \ - --suffix LD_LIBRARY_PATH : "${lib.makeLibraryPath runtimeDeps}" \ - "''${gappsWrapperArgs[@]}" \ - "''${makeWrapperArgs[@]}" + _wrapDotnetProgram $executable fi done - '') + '' - runHook postInstall - ''; + ''); }); in package