summary refs log tree commit diff
path: root/nixos/modules/virtualisation/qemu-vm.nix
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2014-07-30 15:44:47 +0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2014-07-30 16:04:15 +0200
commite68b0c7f5f14b4bef23303ec0316bcce88f05300 (patch)
treef22415f5075e5f622a7e9b990b2d36292566627a /nixos/modules/virtualisation/qemu-vm.nix
parentd45dcf348e451dd56c0c994a894f4c22b653fb71 (diff)
downloadnixlib-e68b0c7f5f14b4bef23303ec0316bcce88f05300.tar
nixlib-e68b0c7f5f14b4bef23303ec0316bcce88f05300.tar.gz
nixlib-e68b0c7f5f14b4bef23303ec0316bcce88f05300.tar.bz2
nixlib-e68b0c7f5f14b4bef23303ec0316bcce88f05300.tar.lz
nixlib-e68b0c7f5f14b4bef23303ec0316bcce88f05300.tar.xz
nixlib-e68b0c7f5f14b4bef23303ec0316bcce88f05300.tar.zst
nixlib-e68b0c7f5f14b4bef23303ec0316bcce88f05300.zip
Mount unionfs-fuse filesystems using the normal fileSystems option
Diffstat (limited to 'nixos/modules/virtualisation/qemu-vm.nix')
-rw-r--r--nixos/modules/virtualisation/qemu-vm.nix37
1 files changed, 17 insertions, 20 deletions
diff --git a/nixos/modules/virtualisation/qemu-vm.nix b/nixos/modules/virtualisation/qemu-vm.nix
index bccf6583e47d..17acd08f086c 100644
--- a/nixos/modules/virtualisation/qemu-vm.nix
+++ b/nixos/modules/virtualisation/qemu-vm.nix
@@ -275,12 +275,10 @@ in
 
     boot.loader.grub.device = mkVMOverride "/dev/vda";
 
-    boot.initrd.supportedFilesystems = optional cfg.writableStore "unionfs-fuse";
-
     boot.initrd.extraUtilsCommands =
       ''
         # We need mke2fs in the initrd.
-        cp ${pkgs.e2fsprogs}/sbin/mke2fs $out/bin
+        cp -f ${pkgs.e2fsprogs}/sbin/mke2fs $out/bin
       '';
 
     boot.initrd.postDeviceCommands =
@@ -303,20 +301,6 @@ in
         chmod 1777 $targetRoot/tmp
 
         mkdir -p $targetRoot/boot
-        ${optionalString cfg.writableStore ''
-          mkdir -p /unionfs-chroot/ro-store
-          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
-        ''}
       '';
 
     # After booting, register the closure of the paths in
@@ -343,12 +327,13 @@ in
     # configuration, where the regular value for the `fileSystems'
     # attribute should be disregarded for the purpose of building a VM
     # test image (since those filesystems don't exist in the VM).
-    fileSystems = mkVMOverride
+    fileSystems = mkVMOverride (
       { "/".device = "/dev/vda";
-        "/nix/store" =
+        ${if cfg.writableStore then "/nix/.ro-store" else "/nix/store"} =
           { device = "store";
             fsType = "9p";
             options = "trans=virtio,version=9p2000.L,msize=1048576,cache=loose";
+            neededForBoot = true;
           };
         "/tmp/xchg" =
           { device = "xchg";
@@ -362,6 +347,18 @@ in
             options = "trans=virtio,version=9p2000.L,msize=1048576";
             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";
+            options = "mode=0755";
+            neededForBoot = true;
+          };
       } // optionalAttrs cfg.useBootLoader
       { "/boot" =
           { device = "/dev/disk/by-label/boot";
@@ -369,7 +366,7 @@ in
             options = "ro";
             noCheck = true; # fsck fails on a r/o filesystem
           };
-      };
+      });
 
     swapDevices = mkVMOverride [ ];
     boot.initrd.luks.devices = mkVMOverride [];