* 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
This commit is contained in:
@@ -85,8 +85,12 @@ in
|
||||
'';
|
||||
|
||||
# Mount the host filesystem via CIFS, and bind-mount the Nix store
|
||||
# of the host into our own filesystem.
|
||||
fileSystems =
|
||||
# of the host into our own filesystem. We use mkOverride to allow
|
||||
# this module to be applied to "normal" NixOS system configuration,
|
||||
# where the regular value for the `fileSystems' attribute should be
|
||||
# disregarded for the purpose of building a VM test image (since
|
||||
# those filesystems don't exist in the VM).
|
||||
fileSystems = pkgs.lib.mkOverride 50 {}
|
||||
[ { mountPoint = "/";
|
||||
device = "/dev/vda";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user