3
0
Fork 0
forked from mirrors/nixpkgs

* Move support for writable Nix stores to qemu-vm.nix.

svn path=/nixos/trunk/; revision=23393
This commit is contained in:
Eelco Dolstra 2010-08-24 12:59:16 +00:00
parent fe2f7eae17
commit 392275f185
2 changed files with 27 additions and 13 deletions

View file

@ -86,6 +86,17 @@ let
''; '';
}; };
virtualisation.writableStore =
mkOption {
default = false;
description =
''
If enabled, the Nix store in the VM is made writable by
layering an AUFS/tmpfs filesystem on top of the host's Nix
store.
'';
};
networking.primaryIPAddress = networking.primaryIPAddress =
mkOption { mkOption {
default = ""; default = "";
@ -163,7 +174,11 @@ in
# CIFS. Also use paravirtualised network and block devices for # CIFS. Also use paravirtualised network and block devices for
# performance. # performance.
boot.initrd.availableKernelModules = boot.initrd.availableKernelModules =
[ "cifs" "virtio_net" "virtio_pci" "virtio_blk" "virtio_balloon" "nls_utf8" ]; [ "cifs" "virtio_net" "virtio_pci" "virtio_blk" "virtio_balloon" "nls_utf8" ]
++ optional cfg.writableStore [ "aufs" ];
boot.extraModulePackages =
optional cfg.writableStore config.boot.kernelPackages.aufs2;
boot.initrd.extraUtilsCommands = boot.initrd.extraUtilsCommands =
'' ''
@ -190,6 +205,16 @@ in
fi fi
''; '';
boot.initrd.postMountCommands =
''
mount -o remount,ro $targetRoot/nix/store
${optionalString cfg.writableStore ''
mkdir /mnt-store-tmpfs
mount -t tmpfs -o "mode=755" none /mnt-store-tmpfs
mount -t aufs -o dirs=/mnt-store-tmpfs=rw:$targetRoot/nix/store=rr none $targetRoot/nix/store
''}
'';
# After booting, register the closure of the paths in # After booting, register the closure of the paths in
# `virtualisation.pathsInNixDB' in the Nix database in the VM. This # `virtualisation.pathsInNixDB' in the Nix database in the VM. This
# allows Nix operations to work in the VM. The path to the # allows Nix operations to work in the VM. The path to the

View file

@ -77,18 +77,7 @@ let
dir = "/tmp/channel"; dir = "/tmp/channel";
}; };
# Make the Nix store in this VM writable using AUFS. This virtualisation.writableStore = true;
# should probably be moved to qemu-vm.nix.
boot.extraModulePackages = [ config.boot.kernelPackages.aufs2 ];
boot.initrd.availableKernelModules = [ "aufs" ];
boot.initrd.postMountCommands =
''
mkdir /mnt-store-tmpfs
mount -t tmpfs -o "mode=755" none /mnt-store-tmpfs
mount -t aufs -o dirs=/mnt-store-tmpfs=rw:$targetRoot/nix/store=rr none $targetRoot/nix/store
'';
virtualisation.pathsInNixDB = channelContents; virtualisation.pathsInNixDB = channelContents;
}; };