diff --git a/pkgs/build-support/vm/default.nix b/pkgs/build-support/vm/default.nix index 7ba67af5cf5a1..45753efca25fb 100644 --- a/pkgs/build-support/vm/default.nix +++ b/pkgs/build-support/vm/default.nix @@ -130,15 +130,15 @@ rec { mkdir -p /fs${storeDir} mount -t 9p store /fs${storeDir} -o trans=virtio,version=9p2000.L,cache=loose,msize=131072 + echo "mounting host's build directory..." + mkdir -p /fs/build + mount -t 9p sa /fs/build -o trans=virtio,version=9p2000.L,cache=loose,msize=131072 + mkdir -p /fs/tmp /fs/run /fs/var mount -t tmpfs -o "mode=1777" none /fs/tmp mount -t tmpfs -o "mode=755" none /fs/run ln -sfn /run /fs/var/run - echo "mounting host's temporary directory..." - mkdir -p /fs/tmp/xchg - mount -t 9p xchg /fs/tmp/xchg -o trans=virtio,version=9p2000.L,msize=131072 - mkdir -p /fs/proc mount -t proc none /fs/proc @@ -169,7 +169,9 @@ rec { stage2Init = writeScript "vm-run-stage2" '' #! ${bash}/bin/sh - source /tmp/xchg/saved-env + source /build/xchg/saved-env + [ -f "''${NIX_ATTRS_SH_FILE-}" ] && source "$NIX_ATTRS_SH_FILE" + source $stdenv/setup # Set the system time from the hardware clock. Works around an # apparent KVM > 1.5.2 bug. @@ -203,8 +205,8 @@ rec { if test -n "$origBuilder" -a ! -e /.debug; then exec < /dev/null ${coreutils}/bin/touch /.debug - $origBuilder $origArgs - echo $? > /tmp/xchg/in-vm-exit + $origBuilder ''${origArgs[*]} + echo $? > /build/xchg/in-vm-exit ${busybox}/bin/mount -o remount,ro dummy / @@ -223,6 +225,7 @@ rec { -nographic -no-reboot \ -device virtio-rng-pci \ -virtfs local,path=${storeDir},security_model=none,mount_tag=store \ + -virtfs local,path=/build,security_model=none,mount_tag=sa \ -virtfs local,path=$TMPDIR/xchg,security_model=none,mount_tag=xchg \ ''${diskImage:+-drive file=$diskImage,if=virtio,cache=unsafe,werror=report} \ -kernel ${kernel}/${img} \ @@ -233,6 +236,8 @@ rec { vmRunCommand = qemuCommand: writeText "vm-run" '' + [ -f "''${NIX_ATTRS_SH_FILE-}" ] && source "$NIX_ATTRS_SH_FILE" + source $stdenv/setup export > saved-env PATH=${coreutils}/bin