From 689b9609512f212ffc27ca013aa9c327b20a772a Mon Sep 17 00:00:00 2001 From: Sander Date: Sun, 23 Feb 2025 01:08:33 +0400 Subject: [PATCH] tasks: use `lib.getExe` to fetch the package binary by default `tasks..binary` is now an optional override, in case `lib.getExe` (i.e. `meta.mainProgram`) returns something that doesn't work. --- src/modules/tasks.nix | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/modules/tasks.nix b/src/modules/tasks.nix index 9f161a218..afe75c661 100644 --- a/src/modules/tasks.nix +++ b/src/modules/tasks.nix @@ -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}"} @@ -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;