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]: 97ed6b4565
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]: 97ed6b4565
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 26eba25577 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.
Those were left-over after 97ed6b4565.
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.
Commit 97ed6b4565 broke the systemd-boot
tests (among others) because of the `hwclock -s` invocation. This was
broken for a while, but not noticed because we didn't have a `set -e`
before.
The error
hwclock: select() to /dev/rtc0 to wait for clock tick timed out
MAY be related to an open QEMU bug[1]: I can't reproduce the error on
aarch64-linux and x86_64-linux with `partitionTableType = "legacy";`.
Also, the issue disappears on x86_64-linux when adding `--directisa`.
However, the invocation was added in f73ff0529e
10 years ago which didn't give any reasoning or pointer to what KVM bug
this may be. Given that this must have happened on an ancient version,
we agreed on removing it altogether[2].
[1] https://gitlab.com/qemu-project/qemu/-/issues/1762
[2] https://github.com/NixOS/nixpkgs/pull/354535#issuecomment-2500791222
This is required for `preVM` which can be arbitrary code: e.g.
`vmTools.createEmptyImage` assumes the presence of `$out` in its default
configuration.
Also, before this patch, `preVM` wasn't even set in the
`__structuredAttrs` case.
Closes#334705
Addresses #205690
The main issue was that the output variable (i.e. `$out` and friends)
didn't exist. I figured the easiest way to add those is to source
`stdenv` here. Given that we build another derivation in this builder,
it's pretty likely that `stdenv` gets pulled already, so I don't expect
a real overhead here.
Also, this mounts `/build` into the VM: this is required to make sure
`.attrs.json` & `.attrs.sh` are available. Dropped the mount of `xchg`
into `/tmp` now since it's also part of `/build`.
Closes#302291Closes#301536
The following things have changed:
* For 5.7+: ZSWAP compressor uses zstd now.
* For 5.11+: ZRAM compressor uses zstd now.
* For 5.13+: kernel modules are compressed with zstd instead of xz.
* For 5.19+: support zstd-compressed firmware.
The modules-closure functionality needed explicit support for copying
over `.zst` files. Also, the VM image builder used busybox's `insmod`
before which doesn't support zstd. Switched to `kmod` and added xz/zstd
as dependencies for it, similar to how it's done for the actual stage1
in d33e52b253. The use of `kmod` here
doesn't seem to be such a big deal since it's only a build-time
dependency.
The deb files we want are no longer available in the Debian mirrors,
so we need to download them from the snapshots we download the package
lists from.
This makes it possible to build the os-prober NixOS test again.
otherwise, eval fails when the experimental no-url-literals feature is activated
unquoted urls are discouraged after https://github.com/NixOS/rfcs/pull/45
This fixes e.g. building the rpm of patchelf as in
pkgs/build-support/vm/test.nix. The glob won't work if there are
multiple spec files but I don't think rpmbuild would work in that case
either.
These gave missing attribute errors. They should have been written as
strings in ae9337179b.
Fixes: ae9337179b ("vm: deprecate phases")
Fixes: 52b10ee872 ("vmTools refactor: don't use huge `with pkgs;`")
These are usually set up by systemd, but there's no systemd in the
VM. /dev/fd is required for <(...) syntax in bash, and I'm sure lots
of things depend on the stdin/stdout/stderr links as well.