summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
authorRobert Hensing <robert@roberthensing.nl>2023-07-31 21:50:23 +0200
committerRobert Hensing <robert@roberthensing.nl>2023-08-01 12:21:06 +0200
commit0ed9e35a220b9de5b9462deba3900605e174809d (patch)
treeb4485f4aef8a907f68d514273028d02fe2cb3458 /pkgs
parent34ee0260ec2efcde59948202b01c5799cb298d6b (diff)
downloadnixpkgs-0ed9e35a220b9de5b9462deba3900605e174809d.tar
nixpkgs-0ed9e35a220b9de5b9462deba3900605e174809d.tar.gz
nixpkgs-0ed9e35a220b9de5b9462deba3900605e174809d.tar.bz2
nixpkgs-0ed9e35a220b9de5b9462deba3900605e174809d.tar.lz
nixpkgs-0ed9e35a220b9de5b9462deba3900605e174809d.tar.xz
nixpkgs-0ed9e35a220b9de5b9462deba3900605e174809d.tar.zst
nixpkgs-0ed9e35a220b9de5b9462deba3900605e174809d.zip
writers: Set mainProgram
Part of https://github.com/NixOS/nixpkgs/pull/246386
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/build-support/writers/scripts.nix24
1 files changed, 17 insertions, 7 deletions
diff --git a/pkgs/build-support/writers/scripts.nix b/pkgs/build-support/writers/scripts.nix
index 7fc47fbcdf9..c43f10f0a2e 100644
--- a/pkgs/build-support/writers/scripts.nix
+++ b/pkgs/build-support/writers/scripts.nix
@@ -25,13 +25,21 @@ rec {
       name = last (builtins.split "/" nameOrPath);
     in
 
-    pkgs.runCommandLocal name (if (types.str.check content) then {
-      inherit content interpreter;
-      passAsFile = [ "content" ];
-    } else {
-      inherit interpreter;
-      contentPath = content;
-    }) ''
+    pkgs.runCommandLocal name (
+      lib.optionalAttrs (nameOrPath == "/bin/${name}") {
+        meta.mainProgram = name;
+      }
+      // (
+        if (types.str.check content) then {
+          inherit content interpreter;
+          passAsFile = [ "content" ];
+        } else {
+          inherit interpreter;
+          contentPath = content;
+        }
+      )
+    )
+    ''
       # On darwin a script cannot be used as an interpreter in a shebang but
       # there doesn't seem to be a limit to the size of shebang and multiple
       # arguments to the interpreter are allowed.
@@ -89,6 +97,8 @@ rec {
       # https://github.com/NixOS/nixpkgs/issues/154203
       # https://github.com/NixOS/nixpkgs/issues/148189
       nativeBuildInputs = [ stdenv.cc.bintools ];
+    } // lib.optionalAttrs (nameOrPath == "/bin/${name}") {
+      meta.mainProgram = name;
     }) ''
       ${compileScript}
       ${lib.optionalString strip