From bf31528ed1a29bc8eb439308edd457634c91c02e Mon Sep 17 00:00:00 2001 From: figsoda Date: Sat, 27 May 2023 11:09:44 -0400 Subject: [PATCH] writeTextFile: set meta.mainProgram based on destination (cherry picked from commit 4b94ae4bc62e7fb2b05da58ca997fd6c3c218a85) --- pkgs/build-support/trivial-builders/default.nix | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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