Hi there, I am trying to restructure my config.
And I have got problem there.
Problem is that my defined value of config.meta.system.binaryCaches seems to be duplicated, and so does values of other lists.
For example, in /etc/nixos/system/options.nix, I define
meta.system.binaryCaches = [ "foo" ];
In config section of configuration.nix, meta.system.binaryCaches would be [ "foo" "foo" ];
However, if I define meta.system.binaryCaches directly inside config section of configuration.nix, there would be no duplication.
I think this may have something to do with my style of writing configuration.nix as a module, but I can’t figure out.
Can you provide a smaller example or a full example with all files? Using the two files you provided it seems that there are several directories missing.
Even though you solved the issue it would be interesting to know what exactly went wrong. It was an unpleasant experience for you, but we can try to improve it so it does not happen again. It would go with the current campaign on improving Nix error messages: Proposal for improving Nix error messages
Here you go.
At the master tree that time, except I used used config.meta instead of meta in meta.nix.example, everything should be enough to produce the “unpleasant experience”.
So to be exact, you used meta which is supposed to correspond to metadata of this module, as described here, which is completely unexpected from the NixOS modules. Unfortunately I don’t know what to do, but I have linked this to the Proposal for improving Nix error messages thread mentioned earlier so I hope this gets fixed.
I think it’s actually not an error in Nix, it could be said “by-design”. But warnings like they are in Rust would definitely be better because not everyone who is writing the configuration would have such a considered thought about what words should avoid.
If nix warns you to take caution, it would be a plus.
I’m not familiar with the internals, but after some thought, my guess is that the problem here is not at all that meta is a reserved word of any sort. Instead, your modules being called meta is just clashing with the builtin module meta. So while it may sound bizaare when you think of it as some words somehow being reserved, as you’re saying here:
It’s probably a much simpler (albeit more far reaching) design flaw at play: module name clashing not being handled well.