summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2016-12-21 20:49:08 +0100
committerEelco Dolstra <edolstra@gmail.com>2016-12-21 20:49:08 +0100
commitea46420fc0f099e7fb73c6594a8340544c3ae4a5 (patch)
treee8659bd6301b91da6d30ad838864c938a5702f04 /nixos
parent9e6ac83f2ad72556ae1f842e4c3a79ea64e77d0c (diff)
downloadnixlib-ea46420fc0f099e7fb73c6594a8340544c3ae4a5.tar
nixlib-ea46420fc0f099e7fb73c6594a8340544c3ae4a5.tar.gz
nixlib-ea46420fc0f099e7fb73c6594a8340544c3ae4a5.tar.bz2
nixlib-ea46420fc0f099e7fb73c6594a8340544c3ae4a5.tar.lz
nixlib-ea46420fc0f099e7fb73c6594a8340544c3ae4a5.tar.xz
nixlib-ea46420fc0f099e7fb73c6594a8340544c3ae4a5.tar.zst
nixlib-ea46420fc0f099e7fb73c6594a8340544c3ae4a5.zip
Use overlayfs instead of unionfs-fuse in the VM tests
Overlayfs is quite a bit faster, e.g. with it the KDE 5 test takes ~7m
instead of ~30m on my laptop (which is still not great, since plain
9pfs is ~4m30s).
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/virtualisation/qemu-vm.nix18
1 files changed, 10 insertions, 8 deletions
diff --git a/nixos/modules/virtualisation/qemu-vm.nix b/nixos/modules/virtualisation/qemu-vm.nix
index 6423432c78b6..041c7dbec702 100644
--- a/nixos/modules/virtualisation/qemu-vm.nix
+++ b/nixos/modules/virtualisation/qemu-vm.nix
@@ -278,7 +278,7 @@ in
         description =
           ''
             If enabled, the Nix store in the VM is made writable by
-            layering a unionfs-fuse/tmpfs filesystem on top of the host's Nix
+            layering an overlay filesystem on top of the host's Nix
             store.
           '';
       };
@@ -395,6 +395,13 @@ in
         chmod 1777 $targetRoot/tmp
 
         mkdir -p $targetRoot/boot
+
+        ${optionalString cfg.writableStore ''
+          echo "mounting overlay filesystem on /nix/store..."
+          mkdir -p 0755 $targetRoot/nix/.rw-store/store $targetRoot/nix/.rw-store/work $targetRoot/nix/store
+          mount -t overlay overlay $targetRoot/nix/store \
+            -o lowerdir=$targetRoot/nix/.ro-store,upperdir=$targetRoot/nix/.rw-store/store,workdir=$targetRoot/nix/.rw-store/work || fail
+        ''}
       '';
 
     # After booting, register the closure of the paths in
@@ -412,7 +419,8 @@ in
       '';
 
     boot.initrd.availableKernelModules =
-      optional (cfg.qemu.diskInterface == "scsi") "sym53c8xx";
+      optional cfg.writableStore "overlay"
+      ++ optional (cfg.qemu.diskInterface == "scsi") "sym53c8xx";
 
     virtualisation.bootDevice =
       mkDefault (if cfg.qemu.diskInterface == "scsi" then "/dev/sda" else "/dev/vda");
@@ -447,12 +455,6 @@ in
             options = [ "trans=virtio" "version=9p2000.L" ];
             neededForBoot = true;
           };
-      } // optionalAttrs cfg.writableStore
-      { "/nix/store" =
-          { fsType = "unionfs-fuse";
-            device = "unionfs";
-            options = [ "allow_other" "cow" "nonempty" "chroot=/mnt-root" "max_files=32768" "hide_meta_files" "dirs=/nix/.rw-store=rw:/nix/.ro-store=ro" ];
-          };
       } // optionalAttrs (cfg.writableStore && cfg.writableStoreUseTmpfs)
       { "/nix/.rw-store" =
           { fsType = "tmpfs";