Can a Nix expression know and make assertions about the flake it was expressed from?
Let’s say I want to make it so only a certain NixOS module option is only ever set in a particular flake from my graph.
Can a Nix expression know and make assertions about the flake it was expressed from?
Let’s say I want to make it so only a certain NixOS module option is only ever set in a particular flake from my graph.
The most idiomatic way would be to set readOnly = true;
on the option declaration so that it can only be set in one place.
But then you lose all the merging and stuff eh ?
Maybe there’s a way to add this functionality.
I’ll try to look at the evaluator.
I’d love to define where options can be used.
There’s also options.<whatever>.definitionsWithLocation
, which uses unsafeGetAttrPos
iirc, the former might be an easier interface to work with though.