libnixf: check builtins. prefix from variable lookups#721
Conversation
496fae8 to
46a12cc
Compare
builtins. prefix from variable lookups
|
Is this correct? The list of top-level names isn't everything in
I don't see any gating in this PR to just those names. |
That list is generated by the NixOS/nix library. Specifically, those values are referred to as
This information is obtained directly from the C++ library and is not encoded in the nixd code. |
builtins_480p.mov@philiptaron See this video, is that expected? |
Wonderful. |
My only concern with this approach is when using this for nixpkgs specifically, is nixpkgs is supposed to eval on multiple implementations & versions of nix. E.g. if a new version of nix adds or remove something from the prelude, nixpkgs wouldn't want to change its linting rules until that change was reflected in all "supported" nix versions (i.e. when we bump I wonder if there is a way to configure this linting and use the C++ information merely as the default? E.g. we could have an --enforce-global true \
--enforce-global false \
--enforce-global map \
--enforce-global throw \
# ...When used, only the explicitly listed "globals" would be treated as prelude values. IDK if such an interface would need a way to both append to the default list or override it? For nixpkgs we'd want to override the list, but maybe others would want a different behaviour? |
|
I would be shocked if Nix introduced a new name to the prelude; they've almost always been added to |
I don't know how comfortable I am relying on that assumption, when the result of something being added/moved/removed would result in linting errors across nixpkgs and fixing those lint errors would break eval on older still-supported versions (and other supported implementations). I guess the questions are 1) when did the prelude last change? 2) are there any plans to move things into or out of the prelude? That would give us an idea of how unreasonably my discomfort is 😁 |
That is more or less what NixOS/nixpkgs#449123 (comment) is trying to figure out. |
|
To avoid problems with later nix versions adding new globals - how about we achieve consistency by enforcing This does not suffer from the same problem. It is also much better to feature detect for Ultimately, we just want consistency and nothing to nit-pick about, right? |
Too pedantic to write |
|
In that case, I agree with @MattSturgeon that it would be best to freeze this list at those globals that were present in 2.18. |
Every globally-exposed primop (not prefixed with
|
|
I understand if this is considered not worth it, currently. But in an ideal world, I'd like to see
While I think this would be useful beyond nixpkgs, it would also allow nixpkgs to handle backwards compatibility if anything does get added to the prelude in the future. Based on @eclairevoyant's comment this seems infrequent and unlikely, but still possible. Personally, I think |
|
Side note: "prelude" isn't a documented term anywhere in nix, I think it's a haskell thing. |
No description provided.