summary refs log tree commit diff
path: root/nixos/modules/virtualisation/qemu-vm.nix
diff options
context:
space:
mode:
authorPeter Simons <simons@cryp.to>2014-08-04 16:51:47 +0200
committerPeter Simons <simons@cryp.to>2014-08-04 16:51:47 +0200
commit2d326e5032fda2210ff84118a526195f0a68bd24 (patch)
treed3af676b9948c865f1e942e1db51862da5e19ad5 /nixos/modules/virtualisation/qemu-vm.nix
parent9253a95f6b3f65ecc701ebb10620acfb6d251f17 (diff)
parentb35770818d70924b2b71ae41ead270fe0be8c826 (diff)
downloadnixlib-2d326e5032fda2210ff84118a526195f0a68bd24.tar
nixlib-2d326e5032fda2210ff84118a526195f0a68bd24.tar.gz
nixlib-2d326e5032fda2210ff84118a526195f0a68bd24.tar.bz2
nixlib-2d326e5032fda2210ff84118a526195f0a68bd24.tar.lz
nixlib-2d326e5032fda2210ff84118a526195f0a68bd24.tar.xz
nixlib-2d326e5032fda2210ff84118a526195f0a68bd24.tar.zst
nixlib-2d326e5032fda2210ff84118a526195f0a68bd24.zip
Merge remote-tracking branch 'origin/master' into staging.
Conflicts:
	pkgs/desktops/e18/enlightenment.nix
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 16c3836887cc..58386ce5cf56 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 [];