From 6ae87b81cc8254b69f8c7293263ad20e31504f2a Mon Sep 17 00:00:00 2001 From: aszlig Date: Thu, 1 Aug 2013 02:10:13 +0200 Subject: [PATCH] qemu-vm: Add new option writableStoreUseTmpfs. This is to use the VMs own disk image instead of a tmpfs in order to avoid eating more memory. Of course, by default we still use the tmpfs in order to not break existing VM tests. I personally don't like the coding style of the option definition, but in order to stay consistent, I followed the overall style in this file. Signed-off-by: aszlig --- modules/virtualisation/qemu-vm.nix | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/modules/virtualisation/qemu-vm.nix b/modules/virtualisation/qemu-vm.nix index 240a3e0b2a8..61d5d20f3be 100644 --- a/modules/virtualisation/qemu-vm.nix +++ b/modules/virtualisation/qemu-vm.nix @@ -114,6 +114,16 @@ let ''; }; + virtualisation.writableStoreUseTmpfs = + mkOption { + default = true; + description = + '' + Use a tmpfs for the writable store instead of writing to the VM's + own filesystem. + ''; + }; + networking.primaryIPAddress = mkOption { default = ""; @@ -297,7 +307,13 @@ in mount --rbind $targetRoot/nix/store /unionfs-chroot/ro-store mkdir /unionfs-chroot/rw-store + ${if cfg.writableStoreUseTmpfs then '' mount -t tmpfs -o "mode=755" none /unionfs-chroot/rw-store + '' else '' + mkdir $targetRoot/.nix-rw-store + mount --bind $targetRoot/.nix-rw-store /unionfs-chroot/rw-store + ''} + unionfs -o allow_other,cow,nonempty,chroot=/unionfs-chroot,max_files=32768,hide_meta_files /rw-store=RW:/ro-store=RO $targetRoot/nix/store ''} '';