Skip to content

Commit

Permalink
tasks: use lib.getExe to fetch the package binary by default
Browse files Browse the repository at this point in the history
`tasks.<name>.binary` is now an optional override, in case
`lib.getExe` (i.e. `meta.mainProgram`) returns something that doesn't
work.
  • Loading branch information
sandydoo committed Feb 22, 2025
1 parent b799e75 commit 689b960
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/modules/tasks.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,14 @@ let
if builtins.isNull command
then null
else
let
binary =
if config.binary != null
then "${pkgs.lib.getBin config.package}/bin/${config.binary}"
else pkgs.lib.getExe config.package;
in
pkgs.writeScript name ''
#!${pkgs.lib.getBin config.package}/bin/${config.binary}
#!${binary}
${lib.optionalString (!isStatus) "set -e"}
${command}
${lib.optionalString (config.exports != [] && !isStatus) "${devenv}/bin/devenv-tasks export ${lib.concatStringsSep " " config.exports}"}
Expand All @@ -28,10 +34,9 @@ let
description = "Command to execute the task.";
};
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 if it differs from from the output of `lib.getExe`.";
default = null;
};
package = lib.mkOption {
type = types.package;
Expand Down

0 comments on commit 689b960

Please sign in to comment.