aboutsummaryrefslogtreecommitdiff
path: root/default.nix
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2009-08-11 01:35:56 +0000
committerEelco Dolstra <eelco.dolstra@logicblox.com>2009-08-11 01:35:56 +0000
commit89ef5c979b0f13f8642376ddcacd1182fbd715c2 (patch)
treede3bbb6e140a79bf4eed98c0b42a115c2faa5bd7 /default.nix
parentebd2fbd24fd3e518d68773e941bb6f3736ee9b91 (diff)
* New nixos-rebuild action: "nixos-rebuild build-vm" builds a virtual
machine containing a replica (minus the state) of the system configuration. This is mostly useful for testing configuration changes prior to doing an actual "nixos-rebuild switch" (or even "nixos-rebuild test"). The VM can be started as follows: $ nixos-rebuild build-vm $ ./result/bin/run-*-vm which starts a KVM/QEMU instance. Additional QEMU options can be passed through the QEMU_OPTS environment variable (e.g. QEMU_OPTS="-redir tcp:8080::80" to forward a host port to the guest). The fileSystem attribute of the regular system configuration is ignored (using mkOverride), because obviously we can't allow the VM to access the host's block devices. Instead, at startup the VM creates an empty disk image in ./<hostname>.qcow2 to store the VM's root filesystem. Building a VM in this way is efficient because the VM shares its Nix store with the host (through a CIFS mount). However, because the Nix store of the host is mounted read-only in the guest, you cannot run Nix build actions inside the VM. Therefore the VM can only be reconfigured by re-running "nixos-rebuild build-vm" on the host and restarting the VM. svn path=/nixos/trunk/; revision=16662
Diffstat (limited to '')
-rw-r--r--default.nix7
1 files changed, 7 insertions, 0 deletions
diff --git a/default.nix b/default.nix
index 3c174ca13e5..f0020c5a1a6 100644
--- a/default.nix
+++ b/default.nix
@@ -7,6 +7,11 @@ let
(import ./lib/eval-config.nix {inherit configuration;})
config optionDeclarations pkgs;
+ vmConfig = (import ./lib/eval-config.nix {
+ inherit configuration;
+ extraModules = [./modules/virtualisation/qemu-vm.nix];
+ }).config;
+
in
{
@@ -14,6 +19,8 @@ in
system = config.system.build.system;
+ vm = vmConfig.system.build.vm;
+
# The following are used by nixos-rebuild.
nixFallback = pkgs.nixUnstable;
manifests = config.installer.manifests;