git.iko.soy/typeable/nixpkgs
on master help sign in
make the /nix/store writable under netboot images
commite710edeecfd6152c0b67357555663e5dbec2c787 authormichael bishop <cleverca22@gmail.com> dateTue 29 Nov 2016, 10:31 (10 years ago) parent28fa4cf
1 file changed+22−6
nixos/modules/installer/netboot/netboot.nix+22−6
nixos/modules/installer/netboot/netboot.nix+22−6
@@ -26,11 +26,6 @@ with lib;
2626 # here and it causes a cyclic dependency.
2727 boot.loader.grub.enable = false;
2828
29− boot.initrd.postMountCommands = ''
30− mkdir -p /mnt-root/nix/store
31− mount -t squashfs /nix-store.squashfs /mnt-root/nix/store
32− '';
33−
3429 # !!! Hack - attributes expected by other modules.
3530 system.boot.loader.kernelFile = "bzImage";
3631 environment.systemPackages = [ pkgs.grub2 pkgs.grub2_efi pkgs.syslinux ];
@@ -42,13 +37,34 @@ with lib;
4237 options = [ "mode=0755" ];
4338 };
4439
40+ # In stage 1, mount a tmpfs on top of /nix/store (the squashfs
41+ # image) to make this a live CD.
42+ fileSystems."/nix/.ro-store" =
43+ { fsType = "squashfs";
44+ device = "../nix-store.squashfs";
45+ options = [ "loop" ];
46+ neededForBoot = true;
47+ };
48+
49+ fileSystems."/nix/.rw-store" =
50+ { fsType = "tmpfs";
51+ options = [ "mode=0755" ];
52+ neededForBoot = true;
53+ };
54+
55+ fileSystems."/nix/store" =
56+ { fsType = "unionfs-fuse";
57+ device = "unionfs";
58+ options = [ "allow_other" "cow" "nonempty" "chroot=/mnt-root" "max_files=32768" "hide_meta_files" "dirs=/nix/.rw-store=rw:/nix/.ro-store=ro" ];
59+ };
60+
4561 boot.initrd.availableKernelModules = [ "squashfs" ];
4662
4763 boot.initrd.kernelModules = [ "loop" ];
4864
4965 # Closures to be copied to the Nix store, namely the init
5066 # script and the top-level system configuration directory.
51− netboot.storeContents =
67+ netboot.storeContents =
5268 [ config.system.build.toplevel ];
5369
5470 # Create the squashfs image that contains the Nix store.