-
-
Notifications
You must be signed in to change notification settings - Fork 17.1k
stdenv: assert that env is an attrset
#426211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
How did a non-attribute set cc @wolfgangwalther @ShamrockLee for structured attrs concerns |
It would pass evaluation and build without issue if |
|
Wow, this is pretty screwy. Maybe it's a kneejerk reaction, I feel like this PR is going in the wrong direction: how can we enforce Reading the linked issue, I saw that @eclairevoyant gave it a 👍🏻 -- maybe you or they could say more about the cases that led to this PR? Is there a derivation (whether in nixpkgs or not) that uses env as non-attrs? |
|
Right, but I mean what would it do? Create an environment variable called |
|
AFAICT, if ❯ nix-build -E "(import ./. {}).callPackage ./test.nix {}" --show-trace
error:
… while calling the 'derivationStrict' builtin
at <nix/derivation-internal.nix>:37:12:
36|
37| strict = derivationStrict drvAttrs;
| ^
38|
… while evaluating derivation 'test-0.0.0'
whose name attribute is located at /home/langsjo/git/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:468:13
… while evaluating attribute 'env' of derivation 'test-0.0.0'
at /home/langsjo/git/nixpkgs/test.nix:28:3:
27|
28| env = lib.map;
| ^
29|
error: cannot coerce the built-in function 'map' to a string: «primop map» |
There was a bug in one of llama.cpp's nix file spotted by @amozeo, where they use I do think that making |
I think I'm gutsy enough to merge that PR now.
Yeah -- I think either I or @SomeoneSerge wrote that bug 😳 Thanks for the real-life example. I do have commit rights over there and I have let the derivation rot somewhat so please tag me on the PR to fix. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to merge a more decisive PR that doesn't allow env to be anything other than an attrset.
This comment was marked as outdated.
This comment was marked as outdated.
isAttrs check on env before passing it to // operatorenv is an attrset
|
@philiptaron there are some Ruby packages which have a pattern of |
Pretty much. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with this approach.
Yeah, let’s fix those. It would have to be done when we turn on structured attributes by default anyway. Looks like This does mean that this is probably a breaking change for out‐of‐tree users, but the fix is trivial enough that I think it’s okay. |
|
@wolfgangwalther Any idea why https://github.com/NixOS/nixpkgs/actions/runs/16358006170/job/46220573630?pr=426211 is unhappy but the eval CI passed, by the way? |
|
Thanks for pinning.
Aside from how Update: Perhaps we need some more tests inside |
Hydra does build packages with no |
OK, I will look into that. In any case, this is an existing issue, not caused by this PR at all. I have seen this for quite a while already. I remember reading somewhere that hydra needs |
Scratch that:
What happens once an assertion fails: The package is removed from the listed attrpaths already. That's the first step of eval, calling I will have to test more, but I think |
It's essentially this already known issue: #397184 (comment) Edit: Also note my conclusion in #397184 (comment). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall, although I'm banking on the other reviews a bit for the details.
Nice to get rid of the unnecessary environment variable, thanks!
c92adf6 to
b937eac
Compare
`env` is now only allowed to be an attribute set in `stdenv.mkDerivation`
`env` is now only allowed to be an attribute set in `stdenv.mkDerivation`
`env` is now only allowed to be an attribute set in `stdenv.mkDerivation`
`env` is now only allowed to be an attribute set in `stdenv.mkDerivation`
This behavior is no longer supported
|
Rebased on master due to CI failure that looked like a GitHub actions issue. |
Resolves #425858
This commit makes derivations built with
stdenv.mkDerivationhave an assert that ensuresenvis a non-derivation attrset.Also drops a test that expects the behavior this PR is disallowing to be allowed.
Things done
nix.conf? (See Nix manual)sandbox = relaxedsandbox = truenix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)Add a 👍 reaction to pull requests you find important.