error message formatting

This commit is contained in:
Ben Burdette 2020-11-09 19:16:50 -07:00
parent 9f2b25ce55
commit d8ef423a18

View file

@ -1366,29 +1366,30 @@ void EvalState::autoCallFunction(Bindings & args, Value & fun, Value & res)
actualArgs->attrs->push_back(*j); actualArgs->attrs->push_back(*j);
} else if (!i.def) { } else if (!i.def) {
throwUndefinedVarError(i.pos, R"(cannot auto-call a function that has an argument without a default value ('%1%') throwUndefinedVarError(i.pos, R"(cannot auto-call a function that has an argument without a default value ('%1%')
An 'auto-call' is when a nix expression is evaluated without any external arguments.
If that nix expression is a function, and that function's arguments all have default
values, then all is well.
But if the function arguments don't have default values, evaluation fails. An 'auto-call' is when a nix expression is evaluated without any external arguments.
If that nix expression is a function, and that function's arguments all have default
values, then all is well.
The classic case for this error is evaluating a nix file with nix-build that expects But if the function arguments don't have default values, evaluation fails.
to be evaluated by callPackage.
# in 'callPackage' format: expression is a function that takes an argument 'stdenv'.
# callPackage would implicitly pull 'stdenv' from nixpkgs, then call this function.
{ stdenv }:
stdenv.mkDerivation {
...
# in 'auto-call' format: nixpkgs is imported explicitly, and used directly. The classic case for this error is evaluating a nix file with nix-build that expects
let to be evaluated by callPackage.
nixpkgs = import <nixpkgs> {}; # in 'callPackage' format: expression is a function that takes an argument 'stdenv'.
in # callPackage would implicitly pull 'stdenv' from nixpkgs, then call this function.
nixpkgs.stdenv.mkDerivation { { stdenv }:
... stdenv.mkDerivation {
...
See this nix pill for more information re callPackage format: # in 'auto-call' format: nixpkgs is imported explicitly, and used directly.
https://nixos.org/guides/nix-pills/callpackage-design-pattern.html)", i.name); let
nixpkgs = import <nixpkgs> {};
in
nixpkgs.stdenv.mkDerivation {
...
More about callPackage:
https://nixos.org/guides/nix-pills/callpackage-design-pattern.html)", i.name);
} }
} }
} }