diff options
author | Cole Helbling <cole.e.helbling@outlook.com> | 2023-03-24 14:22:11 -0700 |
---|---|---|
committer | Cole Helbling <cole.e.helbling@outlook.com> | 2023-03-24 14:22:11 -0700 |
commit | d9f767600fb2f5f0b7e7159cd8638c0701ad6bfc (patch) | |
tree | 18b1aca97c322268e046e99d36cec930c2fc7ef3 /lib/customisation.nix | |
parent | 2e4e45290e8a0e178642ae2414de558ecca0041a (diff) |
lib/customisation: callPackageWith should abort with errors
ofborg relies on the behavior that existed prior to 1c00bf394867b07ed7a908408d8bc1d0afd9fa49, where evaluation would immediately abort due to a missing argument (whether it be an aliased package when `allowAliases = false;` or a typo'd or otherwise nonexistent package). If `callPackageWith` `throw`s instead of `abort`s, the following `nix-env` invocation does not fail fast but instead silently skips the attribute (assuming there is a package that has an aliased package in its `autoArgs`): $ nix-env -qa --json --file . --arg config '{ allowAliases = false; }' &>/dev/null $ echo $? 0 This does change the error output when there is a missing package (for any of the reasons mentioned above), though. Before this change, the errors looked like this: $ nix-build -A hello --arg config '{ allowAliases = false; }' error: … while calling the 'throw' builtin at /home/vin/workspace/vcs/nixpkgs/master/lib/customisation.nix:179:65: 178| 179| in if missingArgs == [] then makeOverridable f allArgs else throw error; | ^ 180| error: Function called without required argument "bash_5" at /home/vin/workspace/vcs/nixpkgs/master/pkgs/applications/misc/hello/default.nix:8, did you mean "bash" or "bashdb"? And the errors now look like this: $ nix-build -A hello --arg config '{ allowAliases = false; }' error: … while calling the 'abort' builtin at /home/vin/workspace/vcs/nixpkgs/master/lib/customisation.nix:179:65: 178| 179| in if missingArgs == [] then makeOverridable f allArgs else abort error; | ^ 180| error: evaluation aborted with the following error message: 'Function called without required argument "bash_5" at /home/vin/workspace/vcs/nixpkgs/master/pkgs/applications/misc/hello/default.nix:8, did you mean "bash" or "bashdb"?'
Diffstat (limited to 'lib/customisation.nix')
-rw-r--r-- | lib/customisation.nix | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/customisation.nix b/lib/customisation.nix index cb3a4b561151f..fe32e890f3571 100644 --- a/lib/customisation.nix +++ b/lib/customisation.nix @@ -176,7 +176,7 @@ rec { # Only show the error for the first missing argument error = errorForArg (lib.head missingArgs); - in if missingArgs == [] then makeOverridable f allArgs else throw error; + in if missingArgs == [] then makeOverridable f allArgs else abort error; /* Like callPackage, but for a function that returns an attribute |