Closed nixinator closed 2 years ago
I think what's going on is that the attributes passed at the point where overrides are enabled do not contain configureFlags
(hence the error), but some function call further down defaults it to [ ]
(haven't taken a look at what that is).
You can guard against this using the or
statement:
nix-repl> cowsay.overrideAttrs(old: { configureFlags = old.configureFlags ++ [ "--new-flag" ]; })
error: attribute 'configureFlags' missing, at (string):1:46
«derivation
nix-repl> cowsay.overrideAttrs(old: { configureFlags = old.configureFlags or [] ++ [ "--new-flag" ]; })
«derivation /nix/store/znjs9q7k6rhdi131wspqz4xks3wshdxw-cowsay-3.04.drv»
I'll update the override docs to add a note about this, since it's often difficult to predict this situation when writing override code :)
Actually I was slightly incorrect about the cause here, what's going on is this:
nix-repl> ({ a ? 1 }@args: args) {}
{ }
What this means is that captures of attribute set parameters (using @
) do not capture defaulted variables. This is actually surprising to me, so thanks for pointing out something new about the language! I'll update the docs accordingly.
if you try
configureFlags has to be populated, if it's empty overriderAttrs can't append to an empty list
however
so i think this is a quirk with overrideAttrs
however is easily fixed with
bizzare huh! i presume the there is no 'old.configureFlags', because it's empty :-) .... quirky?