diff --git a/pkgs/build-support/trivial-builders/default.nix b/pkgs/build-support/trivial-builders/default.nix index e90d0a6d2022..d3cb22a1f535 100644 --- a/pkgs/build-support/trivial-builders/default.nix +++ b/pkgs/build-support/trivial-builders/default.nix @@ -135,9 +135,15 @@ rec { , allowSubstitutes ? false , preferLocalBuild ? true }: + let + matches = builtins.match "/bin/([^/]+)" destination; + in runCommand name - { inherit text executable checkPhase meta allowSubstitutes preferLocalBuild; + { inherit text executable checkPhase allowSubstitutes preferLocalBuild; passAsFile = [ "text" ]; + meta = lib.optionalAttrs (executable && matches != null) { + mainProgram = lib.head matches; + } // meta; } '' target=$out${lib.escapeShellArg destination} @@ -350,8 +356,6 @@ rec { runHook postCheck '' else checkPhase; - - meta.mainProgram = name; }; # Create a C binary