git.iko.soy/typeable/nixpkgs
on master help sign in
make the /nix/store writable under netboot images
e710edemichael bishop
nixos/modules/installer/netboot/netboot.nix+22−6
@@ -26,11 +26,6 @@ with lib;
26 # here and it causes a cyclic dependency.
26 # here and it causes a cyclic dependency.
27 boot.loader.grub.enable = false;
27 boot.loader.grub.enable = false;
28
28
29− boot.initrd.postMountCommands = ''
30− mkdir -p /mnt-root/nix/store
31− mount -t squashfs /nix-store.squashfs /mnt-root/nix/store
32− '';
33−
34 # !!! Hack - attributes expected by other modules.
29 # !!! Hack - attributes expected by other modules.
35 system.boot.loader.kernelFile = "bzImage";
30 system.boot.loader.kernelFile = "bzImage";
36 environment.systemPackages = [ pkgs.grub2 pkgs.grub2_efi pkgs.syslinux ];
31 environment.systemPackages = [ pkgs.grub2 pkgs.grub2_efi pkgs.syslinux ];
@@ -42,13 +37,34 @@ with lib;
42 options = [ "mode=0755" ];
37 options = [ "mode=0755" ];
43 };
38 };
44
39
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+
45 boot.initrd.availableKernelModules = [ "squashfs" ];
61 boot.initrd.availableKernelModules = [ "squashfs" ];
46
62
47 boot.initrd.kernelModules = [ "loop" ];
63 boot.initrd.kernelModules = [ "loop" ];
48
64
49 # Closures to be copied to the Nix store, namely the init
65 # Closures to be copied to the Nix store, namely the init
50 # script and the top-level system configuration directory.
66 # script and the top-level system configuration directory.
51− netboot.storeContents =
67+ netboot.storeContents =
52 [ config.system.build.toplevel ];
68 [ config.system.build.toplevel ];
53
69
54 # Create the squashfs image that contains the Nix store.
70 # Create the squashfs image that contains the Nix store.