You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
{ enable = false; gid = «error: The option `programs._1password.gid' can no longer be used since it's been removed. A preallocated GID will be used instead.
»; package = «derivation /nix/store/43182jvmys5wxs30c196n9a163vg4238-1password-cli-2.28.0.drv»; }
However, if we add --json to our input, we get this output:
error:
… while evaluating attribute 'gid'
… while evaluating the attribute 'value'
at /nix/store/rqicl40jqw5d93l43s1xq0bm6yy0gpx4-source/lib/modules.nix:809:9:
808| in warnDeprecation opt //
809| { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
| ^
810| inherit (res.defsFinal') highestPrio;
… while evaluating the option `programs._1password.gid':
(stack trace truncated; use '--show-trace' to show the full, detailed trace)
error: The option `programs._1password.gid' can no longer be used since it's been removed. A preallocated GID will be used instead.
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
If we evaluated programs._1password.gid directly, like via this input nix 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.
quatquatt
changed the title
nix eval outputs errors differently based on if --json is usednix eval handles errors differently based on if --json is used
Sep 23, 2024
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: