From 689b9609512f212ffc27ca013aa9c327b20a772a Mon Sep 17 00:00:00 2001 From: Sander Date: Sun, 23 Feb 2025 01:08:33 +0400 Subject: [PATCH 1/3] 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; From 905482f5bfceed317714ad13aefa1a5769a2f311 Mon Sep 17 00:00:00 2001 From: Sander Date: Sun, 23 Feb 2025 02:34:10 +0400 Subject: [PATCH 2/3] tasks: fix the bash assertion for tasks that use exports --- src/modules/tasks.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modules/tasks.nix b/src/modules/tasks.nix index afe75c661..6540c6f18 100644 --- a/src/modules/tasks.nix +++ b/src/modules/tasks.nix @@ -35,7 +35,7 @@ let }; binary = lib.mkOption { type = types.nullOr types.str; - description = "Override the binary name if it differs from from the output of `lib.getExe`."; + description = "Override the binary name from the default `package.meta.mainProgram`."; default = null; }; package = lib.mkOption { @@ -123,8 +123,8 @@ in assertions = [ { - assertion = lib.all (task: lib.hasPrefix "bash" task.binary || task.exports == [ ]) (lib.attrValues config.tasks); - message = "The 'exports' option for a task can only be set when 'binary' is set to 'bash' or 'bash-interactive'."; + assertion = lib.all (task: task.package.meta.mainProgram == "bash" || task.binary == "bash" || task.exports == [ ]) (lib.attrValues config.tasks); + message = "The 'exports' option for a task can only be set when 'package' is a bash package."; } ]; From 29cf352d2063a40fb16a293e2288bcfad70f4884 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 22 Feb 2025 22:37:34 +0000 Subject: [PATCH 3/3] Auto generate docs/reference/options.md --- docs/reference/options.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/reference/options.md b/docs/reference/options.md index e56f0a93a..836ba58bf 100644 --- a/docs/reference/options.md +++ b/docs/reference/options.md @@ -83325,17 +83325,17 @@ list of string -Override the binary name if it doesn’t match package name +Override the binary name from the default ` package.meta.mainProgram `. *Type:* -string +null or string *Default:* -` config.package.pname ` +` null ` *Declared by:* - [https://github.com/cachix/devenv/blob/main/src/modules/tasks.nix](https://github.com/cachix/devenv/blob/main/src/modules/tasks.nix)