-
-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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
runInLinuxVM: refactor structuredAttrs support, fix disko #360413
runInLinuxVM: refactor structuredAttrs support, fix disko #360413
Conversation
Those were left-over after 97ed6b4. This also cleans up some confusion around TMPDIR. We had the following lines: mkdir xchg ... cd $TMPDIR ... path=$TMPDIR/xchg Those only worked because the **current directory** is the same as $TMPDIR. Both are /build by default. To refer to the same directory in two different ways is very confusing at best.
The export to saved-env was very intentionally done at the very beginning of vmRunCommand, even jumping through extra hoops just to avoid the PATH variable from polluting the saved variable. In 26eba25 we loaded stdenv in the wrong place, we should do it after saving the previous environment. This is also more consistent with the order of how we load those values back in stage2Init.
In [1] we started sourcing stdenv/setup in stage2Init to allow for structuredAttrs. We failed to take the changed NIX_BUILD_TOP etc. variables into account. We need to load stdenv/setup after changing them, because the structuredAttrs startup code makes use of it. [1]: 97ed6b4
This makes it simpler to copy more files to xchg for the structuredAttrs case in the next commit.
…tory The approach taken in [1] breaks down as soon as vmRunCommand is manually called with an overriden TMPDIR, like disko does it. /build will just not be available. By moving the .attrs.sh file into the xchg folder explicitly, we can all the "exchange infrastructure" the same as before, thus avoid more breakage. This reverts some parts of [1]. [1]: 97ed6b4
e7755a5
to
d2593f0
Compare
I'm pretty sure this also fixes #359782 because of
Sorry, doing it the other way round was a bad decision. |
Yes, I think so, too. |
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.
This indeed makes the reproducer from #359782 build (as well as hello
with/without structured attrs and the systemd-boot tests also look good).
As mentioned before, I think this is the better approach.
@Mindavi does this also fix the issues you had? If so, I'd go ahead and merge.
Sorry for the inconvenience!
Thank you so much! This mostly fixes my issue, but I'm still getting this error when running the script generated by disko:
The line I don't even know how it's possible for Call order is Maybe that line could just be wrapped with an |
I'd rather not do that, because this would silently hide other problems. We should find out why $stdenv is not set here. |
I think for disko, this line is the problem: This clears all other env-vars, that we had saved previously - including Maybe make |
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.
Awesome! Yes, that was it! So from my side, this is good to merge 👍
Fixes #900 This was caused by NixOS/nixpkgs#354535 originally. The breaking changes introduced there have been resolved by NixOS/nixpkgs#360413, but one addition survived, which was the line `source $stdenv/setup`. Because we used `>` instead of `>>`, `saved-env` was overwritten, so even with the second PR, the script failed with the following error: /nix/store/pw...ykc-vm-run-stage2: line 16: stdenv: unbound variable Once this and the second PR mentioned above are merged, #903 will be unblocked.
In #354535 we fixed runInLinuxVM with structuredAttrs. However, this broke some out of tree users, e.g. disko: nix-community/disko#900.
In this series of commits I'm going through the structuredAttrs support for runInLinuxVM step-by-step again. After some cleanups and improvements, I decided to change the approach a bit. To make
.attrs.sh
available in stage2, we mounted the/build
folder instead of only/tmp/xchg
in #354535. I'm reverting back to/tmp/xchg
here and instead am copying the attrs files into that folder as well.This makes cases like disko work, which:
saved-env
file in that directory anyway: https://github.com/nix-community/disko/blob/b71e3faca99b40fb801f03fd950fbefbbba691a4/lib/make-disk-image.nix#L204This was previously not picked up anymore after changing the folder to
/build
.Could you test / confirm that this branch fixes it for you, @iFreilicht?
cc @Ma27
Resolves #359782
Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-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.