-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
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
stdenv: support opt-in __structuredAttrs #175649
Conversation
I think this is really good to get in, but if an RFC is needed (work has been done on nix to make this work, so I'm really not sure why we'd do that but then require a RFC here) we should do that first. Some documentation on how to migrate would be nice (just an url would be a good start already). Will do some tests soon and then I'm okay with getting this in. Would be good to have some idea of how we'll handle migration though. |
Should a file be converted to __structuredAttrs as example? |
6b08af4
to
415be9b
Compare
1a497ed
to
9cea674
Compare
there's a issue with $ $NIXGITS/nix/outputs/out/bin/nix develop --extra-experimental-features 'flakes nix-command' ".#stdenv.__bootPackages.stdenv.__bootPackages.stdenv.__bootPackages.stdenv.__bootPackages.xz"
error: builder for '/nix/store/8lx3d0d59vss0hczpd08y882688hirid-xz-5.2.5-env.drv' failed with exit code 1;
last 2 log lines:
> structuredAttrs is enabled
> /nix/store/ml6njbj66c2r6h6wvn7id2kvx9gnrnxc-get-env.sh: line 129: /nix/store/ml6njbj66c2r6h6wvn7id2kvx9gnrnxc-get-env.sh: Permission denied
For full logs, run 'nix log /nix/store/8lx3d0d59vss0hczpd08y882688hirid-xz-5.2.5-env.drv'. if i apply this path(a simplified version of what i tried) diff --git a/src/nix/get-env.sh b/src/nix/get-env.sh
index 42c806450..f554fd3fd 100644
--- a/src/nix/get-env.sh
+++ b/src/nix/get-env.sh
@@ -114,11 +114,7 @@ __escapeString() {
# In case of `__structuredAttrs = true;` the list of outputs is an associative
# array with a format like `outname => /nix/store/hash-drvname-outname`, so `__olist`
# must contain the array's keys (hence `${!...[@]}`) in this case.
-if [ -e .attrs.sh ]; then
- __olist="${!outputs[@]}"
-else
- __olist=$outputs
-fi
+__olist=$outputs
for __output in $__olist; do
if [[ -z $__done ]]; then then i get
|
954f5ac
to
4661744
Compare
23702fc
to
cd9ad64
Compare
stdenv: error if using {prepend,append}ToVar on associative array i don't know how to prepend to associative array
cd9ad64
to
11c3127
Compare
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.
Docs LGTM!
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.
Without opting in, this builds at least
- nixosTests.simple
- nixosTests.acme
- hci
- haskell
- rust
- go
- a whole bunch of python, llvm, texlive, nix, ..., through dependencies of the above
This makes me confident that this won't break staging.
🚀 |
TODO fill #205690 with the TODO comments i posted here |
Bisect claims 238a605
|
Plausible explanation: $ env=/nix/foo
$ echo "${!env[@]}"
0
$ for envVar in "${!env[@]}"; do declare -x "$envVar=${env[$envVar]}"; done
bash: declare: `0=/nix/foo': not a valid identifier Proposed fix: use |
Or, probably better, just check that if [[ ${env@a} == *A* ]]; then ...; fi (requires Bash 5+, can we assume that?) |
probably also solves similar errors in the future.
We should maybe do that in addition to the above just to be sure.
stdenv always has it IIRC |
this isn't a internal variable or a structured attrs specific thing so im leaving the name as env
sounds good
adding
|
Fair. Maybe we can simply condition that block on whether |
@@ -473,6 +481,17 @@ else let | |||
else true); | |||
}; | |||
|
|||
checkedEnv = | |||
let | |||
overlappingNames = lib.intersectLists (lib.attrNames env) (lib.attrNames derivationArg); |
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.
lib.intersectLists has quadratic runtime behavior. Will that be a problem?
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.
We should probably use builtins.attrNames (builtins.intersectAttrs env derivationArg)
instead.
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.
Or maybe change the implementation of intersectLists
to do that by default?
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.
intersectLists
has to work with any type of elements, not just strings (or strings-that-can-be-attribute-names, which I'm not sure whether that's a different type)
But we could have intersectListsOfStrings
, I guess.
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.
It looks like there's a function lib.attrsets.unionOfDisjoint
. We could probably just use that, but that would make the error message worse.
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.
Description of changes
supersedes #85042
Read #72074
Built hello with structuredAttrs
Things done
sandbox = true
set innix.conf
? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)nixos/doc/manual/md-to-db.sh
to update generated release notes