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 ]]; thenthen 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
roberth
left a comment
There was a problem hiding this comment.
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 identifierProposed 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 |
|
|
||
| checkedEnv = | ||
| let | ||
| overlappingNames = lib.intersectLists (lib.attrNames env) (lib.attrNames derivationArg); |
There was a problem hiding this comment.
lib.intersectLists has quadratic runtime behavior. Will that be a problem?
There was a problem hiding this comment.
We should probably use builtins.attrNames (builtins.intersectAttrs env derivationArg) instead.
There was a problem hiding this comment.
Or maybe change the implementation of intersectLists to do that by default?
There was a problem hiding this comment.
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.
It looks like there's a function lib.attrsets.unionOfDisjoint. We could probably just use that, but that would make the error message worse.

Description of changes
supersedes #85042
Read #72074
Built hello with structuredAttrs
Things done
sandbox = trueset 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.shto update generated release notes