Loading pkgs/build-support/vm/default.nix +19 −23 Original line number Diff line number Diff line Loading @@ -88,10 +88,6 @@ rec { set -- $(IFS==; echo $o) command=$2 ;; out=*) set -- $(IFS==; echo $o) export out=$2 ;; esac done Loading Loading @@ -129,15 +125,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 Loading @@ -153,7 +149,7 @@ rec { fi echo "starting stage 2 ($command)" exec switch_root /fs $command $out exec switch_root /fs $command ''; Loading @@ -169,11 +165,12 @@ rec { stage2Init = writeScript "vm-run-stage2" '' #! ${bash}/bin/sh set -euo pipefail source /build/xchg/saved-env if [ -f "''${NIX_ATTRS_SH_FILE-}" ]; then source "$NIX_ATTRS_SH_FILE" source /tmp/xchg/saved-env if [ -f /tmp/xchg/.attrs.sh ]; then source /tmp/xchg/.attrs.sh export NIX_ATTRS_JSON_FILE=/tmp/xchg/.attrs.json export NIX_ATTRS_SH_FILE=/tmp/xchg/.attrs.sh fi source $stdenv/setup export NIX_STORE=${storeDir} export NIX_BUILD_TOP=/tmp Loading @@ -181,6 +178,8 @@ rec { export PATH=/empty cd "$NIX_BUILD_TOP" source $stdenv/setup if ! test -e /bin/sh; then ${coreutils}/bin/mkdir -p /bin ${coreutils}/bin/ln -s ${bash}/bin/sh /bin/sh Loading @@ -205,7 +204,7 @@ rec { declare -a argsArray=() concatTo argsArray origArgs "$origBuilder" "''${argsArray[@]}" echo $? > /build/xchg/in-vm-exit echo $? > /tmp/xchg/in-vm-exit ${busybox}/bin/mount -o remount,ro dummy / Loading @@ -224,8 +223,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 \ -virtfs local,path=xchg,security_model=none,mount_tag=xchg \ ''${diskImage:+-drive file=$diskImage,if=virtio,cache=unsafe,werror=report} \ -kernel ${kernel}/${img} \ -initrd ${initrd}/initrd \ Loading @@ -235,15 +233,15 @@ rec { vmRunCommand = qemuCommand: writeText "vm-run" '' ${coreutils}/bin/mkdir xchg export > xchg/saved-env PATH=${coreutils}/bin if [ -f "''${NIX_ATTRS_SH_FILE-}" ]; then cp $NIX_ATTRS_JSON_FILE $NIX_ATTRS_SH_FILE xchg source "$NIX_ATTRS_SH_FILE" fi source $stdenv/setup export > saved-env PATH=${coreutils}/bin mkdir xchg mv saved-env xchg/ eval "$preVM" Loading @@ -261,8 +259,6 @@ rec { cat > ./run-vm <<EOF #! ${bash}/bin/sh ''${diskImage:+diskImage=$diskImage} TMPDIR=$TMPDIR cd $TMPDIR ${qemuCommand} EOF Loading pkgs/build-support/vm/test.nix +1 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ in buildPatchelfInVM = runInLinuxVM patchelf; buildHelloInVM = runInLinuxVM hello; buildStructuredAttrsHelloInVM = runInLinuxVM (hello.overrideAttrs { __structuredAttrs = true; }); buildPcmanrmInVM = runInLinuxVM (pcmanfm.overrideAttrs (old: { # goes out-of-memory with many cores Loading Loading
pkgs/build-support/vm/default.nix +19 −23 Original line number Diff line number Diff line Loading @@ -88,10 +88,6 @@ rec { set -- $(IFS==; echo $o) command=$2 ;; out=*) set -- $(IFS==; echo $o) export out=$2 ;; esac done Loading Loading @@ -129,15 +125,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 Loading @@ -153,7 +149,7 @@ rec { fi echo "starting stage 2 ($command)" exec switch_root /fs $command $out exec switch_root /fs $command ''; Loading @@ -169,11 +165,12 @@ rec { stage2Init = writeScript "vm-run-stage2" '' #! ${bash}/bin/sh set -euo pipefail source /build/xchg/saved-env if [ -f "''${NIX_ATTRS_SH_FILE-}" ]; then source "$NIX_ATTRS_SH_FILE" source /tmp/xchg/saved-env if [ -f /tmp/xchg/.attrs.sh ]; then source /tmp/xchg/.attrs.sh export NIX_ATTRS_JSON_FILE=/tmp/xchg/.attrs.json export NIX_ATTRS_SH_FILE=/tmp/xchg/.attrs.sh fi source $stdenv/setup export NIX_STORE=${storeDir} export NIX_BUILD_TOP=/tmp Loading @@ -181,6 +178,8 @@ rec { export PATH=/empty cd "$NIX_BUILD_TOP" source $stdenv/setup if ! test -e /bin/sh; then ${coreutils}/bin/mkdir -p /bin ${coreutils}/bin/ln -s ${bash}/bin/sh /bin/sh Loading @@ -205,7 +204,7 @@ rec { declare -a argsArray=() concatTo argsArray origArgs "$origBuilder" "''${argsArray[@]}" echo $? > /build/xchg/in-vm-exit echo $? > /tmp/xchg/in-vm-exit ${busybox}/bin/mount -o remount,ro dummy / Loading @@ -224,8 +223,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 \ -virtfs local,path=xchg,security_model=none,mount_tag=xchg \ ''${diskImage:+-drive file=$diskImage,if=virtio,cache=unsafe,werror=report} \ -kernel ${kernel}/${img} \ -initrd ${initrd}/initrd \ Loading @@ -235,15 +233,15 @@ rec { vmRunCommand = qemuCommand: writeText "vm-run" '' ${coreutils}/bin/mkdir xchg export > xchg/saved-env PATH=${coreutils}/bin if [ -f "''${NIX_ATTRS_SH_FILE-}" ]; then cp $NIX_ATTRS_JSON_FILE $NIX_ATTRS_SH_FILE xchg source "$NIX_ATTRS_SH_FILE" fi source $stdenv/setup export > saved-env PATH=${coreutils}/bin mkdir xchg mv saved-env xchg/ eval "$preVM" Loading @@ -261,8 +259,6 @@ rec { cat > ./run-vm <<EOF #! ${bash}/bin/sh ''${diskImage:+diskImage=$diskImage} TMPDIR=$TMPDIR cd $TMPDIR ${qemuCommand} EOF Loading
pkgs/build-support/vm/test.nix +1 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ in buildPatchelfInVM = runInLinuxVM patchelf; buildHelloInVM = runInLinuxVM hello; buildStructuredAttrsHelloInVM = runInLinuxVM (hello.overrideAttrs { __structuredAttrs = true; }); buildPcmanrmInVM = runInLinuxVM (pcmanfm.overrideAttrs (old: { # goes out-of-memory with many cores Loading