nix eval
handles errors differently based on if --json
is used
#11576
Labels
nix eval
handles errors differently based on if --json
is used
#11576
Describe the bug
When evaluating a higher-level option in a config with
nix eval
, it ignores an encountered value that would cause an error. Given this input while cd'ed into your configuration (replace MYHOSTNAME with your hostname)nix eval ".#nixosConfigurations.MYHOSTNAME.config.programs._1password"
It provides this output:
However, if we add --json to our input, we get this output:
It seems that when
nix eval
is used with--json
, it doesn't traverse as low down when it comes to catching errors. Keep in mind that none of these values are set in my configuration: this is just based on the defaults for the module.Expected behavior
I think the behavior without
--json
is more intuitive. An error that would be encountered upon setting a value doesn't make sense if you don't have that value set.I do think that
nix eval
's behavior isn't perfect when it comes to errors. For example:It still prints traces when it encounters a deprecated option, even if it's not being used in the configuration
programs._1password.gid
directly, like via this inputnix eval ".#nixosConfigurations.MYHOSTNAME.config.programs._1password.gid"
, we get an error, even though the value isn't set in our configuration. Note that adding--json
has the same behavior here.However, I think these issues are separate and can be tracked separately.
nix-env --version
outputnix-env (Nix) 2.24.7
Priorities
Add 👍 to issues you find important.
The text was updated successfully, but these errors were encountered: