Skip to content

Commit 974ef39

Browse files
authored
Merge pull request #1756 from mmlb/fix-binary-for-scripts
scripts: use lib.getExe to fetch the package binary by default
2 parents 53be042 + aaa987d commit 974ef39

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/modules/scripts.nix

+10-6
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@ let
2121
defaultText = lib.literalExpression "pkgs.bash";
2222
};
2323
binary = lib.mkOption {
24-
type = types.str;
25-
description = "Override the binary name if it doesn't match package name";
26-
default = config.package.pname;
27-
defaultText = lib.literalExpression "config.package.pname";
24+
type = types.nullOr types.str;
25+
description = "Override the binary name from the default `package.meta.mainProgram`";
26+
default = null;
2827
};
2928
description = lib.mkOption {
3029
type = types.str;
@@ -37,10 +36,15 @@ let
3736
};
3837
};
3938

40-
config.scriptPackage =
39+
config.scriptPackage = let
40+
binary =
41+
if config.binary != null
42+
then "${pkgs.lib.getBin config.package}/bin/${config.binary}"
43+
else pkgs.lib.getExe config.package;
44+
in
4145
lib.hiPrioSet (
4246
pkgs.writeScriptBin name ''
43-
#!${pkgs.lib.getBin config.package}/bin/${config.binary}
47+
#!${binary}
4448
${config.exec}
4549
''
4650
);

0 commit comments

Comments
 (0)