From aaa987d8c74375e15d42cbb318afa069d0b90beb Mon Sep 17 00:00:00 2001 From: Manuel Mendez Date: Thu, 27 Feb 2025 10:28:56 -0500 Subject: [PATCH] scripts: use lib.getExe to fetch the package binary by default `scripts..binary` is now an optional override, in case `lib.getExe` (i.e. `meta.mainProgram`) returns something that doesn't work. This fixes an issue in nixpkgs/master where the pname for bash is changing to bash-interactive by default. Using the pname as the name of the binary breaks scripts. --- src/modules/scripts.nix | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/modules/scripts.nix b/src/modules/scripts.nix index 58386dd05..fa51ef7bf 100644 --- a/src/modules/scripts.nix +++ b/src/modules/scripts.nix @@ -21,10 +21,9 @@ let defaultText = lib.literalExpression "pkgs.bash"; }; binary = lib.mkOption { - type = types.str; - description = "Override the binary name if it doesn't match package name"; - default = config.package.pname; - defaultText = lib.literalExpression "config.package.pname"; + type = types.nullOr types.str; + description = "Override the binary name from the default `package.meta.mainProgram`"; + default = null; }; description = lib.mkOption { type = types.str; @@ -37,10 +36,15 @@ let }; }; - config.scriptPackage = + config.scriptPackage = let + binary = + if config.binary != null + then "${pkgs.lib.getBin config.package}/bin/${config.binary}" + else pkgs.lib.getExe config.package; + in lib.hiPrioSet ( pkgs.writeScriptBin name '' - #!${pkgs.lib.getBin config.package}/bin/${config.binary} + #!${binary} ${config.exec} '' );