From 6dafee8d6704957e123de1b51d3e406848f4aac8 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 16 Oct 2013 11:36:09 +0200 Subject: Fix runInMachine It requires a writable /nix/store to store the build result. Also, wait until we've reached multi-user.target before doing the build, and do a sync at the end to ensure all data to $out is properly written. http://hydra.nixos.org/build/6496716 --- nixos/lib/testing.nix | 7 ++++++- nixos/modules/virtualisation/qemu-vm.nix | 3 +-- nixos/tests/run-in-machine.nix | 6 ++---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/nixos/lib/testing.nix b/nixos/lib/testing.nix index 7be0903ed3a8..3407229e921a 100644 --- a/nixos/lib/testing.nix +++ b/nixos/lib/testing.nix @@ -176,7 +176,10 @@ rec { let vm = buildVM { } [ machine - { key = "hostname"; networking.hostName = "client"; } + { key = "run-in-machine"; + networking.hostName = "client"; + nix.readOnlyStore = false; + } ]; buildrunner = writeText "vm-build" '' @@ -192,9 +195,11 @@ rec { testscript = '' startAll; + $client->waitForUnit("multi-user.target"); ${preBuild} $client->succeed("env -i ${pkgs.bash}/bin/bash ${buildrunner} /tmp/xchg/saved-env >&2"); ${postBuild} + $client->succeed("sync"); # flush all data before pulling the plug ''; vmRunCommand = writeText "vm-run" '' diff --git a/nixos/modules/virtualisation/qemu-vm.nix b/nixos/modules/virtualisation/qemu-vm.nix index 5b521a455470..708b462e0e5d 100644 --- a/nixos/modules/virtualisation/qemu-vm.nix +++ b/nixos/modules/virtualisation/qemu-vm.nix @@ -295,7 +295,7 @@ in boot.initrd.postMountCommands = '' - # Mark this as a NixOS machinex. + # Mark this as a NixOS machine. mkdir -p $targetRoot/etc echo -n > $targetRoot/etc/NIXOS @@ -303,7 +303,6 @@ in chmod 1777 $targetRoot/tmp mkdir -p $targetRoot/boot - mount -o remount,ro $targetRoot/nix/store ${optionalString cfg.writableStore '' mkdir -p /unionfs-chroot/ro-store mount --rbind $targetRoot/nix/store /unionfs-chroot/ro-store diff --git a/nixos/tests/run-in-machine.nix b/nixos/tests/run-in-machine.nix index 75bd161ec9ef..8efe26c17082 100644 --- a/nixos/tests/run-in-machine.nix +++ b/nixos/tests/run-in-machine.nix @@ -1,10 +1,8 @@ -{ nixpkgs ? -, system ? builtins.currentSystem -}: +{ system ? builtins.currentSystem }: with import ../lib/testing.nix { inherit system; }; runInMachine { - drv = (import nixpkgs { inherit system; }).aterm; + drv = pkgs.patchelf; machine = { config, pkgs, ... }: { services.sshd.enable = true; }; } -- cgit 1.4.1