runInLinuxVM: re-add sourcing of stdenv & .attrs.sh

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.
This commit is contained in:
Maximilian Bosch 2024-11-24 13:10:26 +01:00
parent ecdda28a3a
commit 26eba25577
No known key found for this signature in database

View File

@ -240,6 +240,10 @@ rec {
vmRunCommand = qemuCommand: writeText "vm-run" '' vmRunCommand = qemuCommand: writeText "vm-run" ''
if [ -f "''${NIX_ATTRS_SH_FILE-}" ]; then
source "$NIX_ATTRS_SH_FILE"
fi
source $stdenv/setup
export > saved-env export > saved-env
PATH=${coreutils}/bin PATH=${coreutils}/bin