about summary refs log tree commit diff
path: root/modules/virtualisation
diff options
context:
space:
mode:
authoraszlig <aszlig@redmoonstudios.org>2013-08-01 02:10:13 +0200
committeraszlig <aszlig@redmoonstudios.org>2013-08-01 02:10:13 +0200
commit6ae87b81cc8254b69f8c7293263ad20e31504f2a (patch)
tree199d07429a487db535f21a8fe8594448cb251c65 /modules/virtualisation
parentb32ef4dbef492ffd65681813924c247da9ae8ac6 (diff)
downloadnixlib-6ae87b81cc8254b69f8c7293263ad20e31504f2a.tar
nixlib-6ae87b81cc8254b69f8c7293263ad20e31504f2a.tar.gz
nixlib-6ae87b81cc8254b69f8c7293263ad20e31504f2a.tar.bz2
nixlib-6ae87b81cc8254b69f8c7293263ad20e31504f2a.tar.lz
nixlib-6ae87b81cc8254b69f8c7293263ad20e31504f2a.tar.xz
nixlib-6ae87b81cc8254b69f8c7293263ad20e31504f2a.tar.zst
nixlib-6ae87b81cc8254b69f8c7293263ad20e31504f2a.zip
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 <aszlig@redmoonstudios.org>
Diffstat (limited to 'modules/virtualisation')
-rw-r--r--modules/virtualisation/qemu-vm.nix16
1 files changed, 16 insertions, 0 deletions
diff --git a/modules/virtualisation/qemu-vm.nix b/modules/virtualisation/qemu-vm.nix
index 240a3e0b2a80..61d5d20f3be2 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
       ''}
     '';