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>
This commit is contained in:
aszlig 2013-08-01 02:10:13 +02:00
parent b32ef4dbef
commit 6ae87b81cc
No known key found for this signature in database
GPG Key ID: D0EBD0EC8C2DC961

View File

@ -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
''}
'';