diff options
author | David Arnold <dgx.arnold@gmail.com> | 2021-08-03 14:36:07 -0500 |
---|---|---|
committer | David Arnold <dgx.arnold@gmail.com> | 2021-08-03 15:05:52 -0500 |
commit | 2af2d3146d79866ae65ca1883527daa010669b07 (patch) | |
tree | a86ed30edaf8474e53b623277bd404be73737303 | |
parent | 8ff76e34e075907aa700d44555090b7b45f37d44 (diff) | |
download | nixpkgs-2af2d3146d79866ae65ca1883527daa010669b07.tar nixpkgs-2af2d3146d79866ae65ca1883527daa010669b07.tar.gz nixpkgs-2af2d3146d79866ae65ca1883527daa010669b07.tar.bz2 nixpkgs-2af2d3146d79866ae65ca1883527daa010669b07.tar.lz nixpkgs-2af2d3146d79866ae65ca1883527daa010669b07.tar.xz nixpkgs-2af2d3146d79866ae65ca1883527daa010669b07.tar.zst nixpkgs-2af2d3146d79866ae65ca1883527daa010669b07.zip |
nixos/boot-media: soft-force entire fs layout
https://github.com/NixOS/nixpkgs/pull/131760 was made to avo a speicific configuration conflict that errored out for multiple definitions of "/" when the installer where overlayed on any existing host configuration. --- Problem 1: It turns out that in also other mountpoints can coflict. Solution 1: use `mkOverride 60` for all mountpoints (even for the ones unlikely causing confilct for consistency sake) --- Problem 2: It turns out that on an installation media for a fresh machine (before formatting), we usually don't have any devices yet formatted. However defining for example `fileSystems.<nme>.device = "/dev/disk/by-label/...", in newer versions of nixos, seems to make the system startup fail. Similarily waiting for a non-existent swap device does not make the startup fail, but has a 1:30 min timeout. Solution 2: For an installation medium, soft-override ("unless users know what they are doing") the entire `fileSystems` and `swapDevices` definitions.
-rw-r--r-- | nixos/modules/installer/cd-dvd/installation-cd-base.nix | 6 | ||||
-rw-r--r-- | nixos/modules/installer/cd-dvd/iso-image.nix | 101 | ||||
-rw-r--r-- | nixos/modules/installer/netboot/netboot.nix | 18 |
3 files changed, 68 insertions, 57 deletions
diff --git a/nixos/modules/installer/cd-dvd/installation-cd-base.nix b/nixos/modules/installer/cd-dvd/installation-cd-base.nix index aecb65b8c57..ec837b432ce 100644 --- a/nixos/modules/installer/cd-dvd/installation-cd-base.nix +++ b/nixos/modules/installer/cd-dvd/installation-cd-base.nix @@ -30,6 +30,12 @@ with lib; # Add Memtest86+ to the CD. boot.loader.grub.memtest86.enable = true; + # On a fresh machine, before formatting, an installation + # media cannot assume an existing file system layout such + # as might be defined by the encapsulated host config. + swapDevices = mkOverride 60 [ ]; + fileSystems = mkOverride 60 config.lib.isoFileSystems; + boot.postBootCommands = '' for o in $(</proc/cmdline); do case "$o" in diff --git a/nixos/modules/installer/cd-dvd/iso-image.nix b/nixos/modules/installer/cd-dvd/iso-image.nix index f0384513247..1f59e8cb34d 100644 --- a/nixos/modules/installer/cd-dvd/iso-image.nix +++ b/nixos/modules/installer/cd-dvd/iso-image.nix @@ -614,6 +614,58 @@ in }; }; + # store them in lib so we can set the same fileSystems with a + # higher prio on installation media + # This module is often over-layed onto an existing host config + # that defines `fileSystems`. We use mkOverride 60 to override + # standard values, but at the same time leave room for mkForce + # values targeted at the image build. + config.lib.isoFileSystems = { + "/" = mkOverride 60 + { + fsType = "tmpfs"; + options = [ "mode=0755" ]; + }; + + # Note that /dev/root is a symlink to the actual root device + # specified on the kernel command line, created in the stage 1 + # init script. + "/iso" = mkOverride 60 + { device = "/dev/root"; + neededForBoot = true; + noCheck = true; + }; + + # In stage 1, mount a tmpfs on top of /nix/store (the squashfs + # image) to make this a live CD. + "/nix/.ro-store" = mkOverride 60 + { fsType = "squashfs"; + device = "/iso/nix-store.squashfs"; + options = [ "loop" ]; + neededForBoot = true; + }; + + "/nix/.rw-store" = mkOverride 60 + { fsType = "tmpfs"; + options = [ "mode=0755" ]; + neededForBoot = true; + }; + + "/nix/store" = mkOverride 60 + { fsType = "overlay"; + device = "overlay"; + options = [ + "lowerdir=/nix/.ro-store" + "upperdir=/nix/.rw-store/store" + "workdir=/nix/.rw-store/work" + ]; + depends = [ + "/nix/.ro-store" + "/nix/.rw-store/store" + "/nix/.rw-store/work" + ]; + }; + }; config = { assertions = [ @@ -653,54 +705,7 @@ in "boot.shell_on_fail" ]; - fileSystems."/" = - # This module is often over-layed onto an existing host config - # that defines `/`. We use mkOverride 60 to override standard - # values, but at the same time leave room for mkForce values - # targeted at the image build. - { fsType = mkOverride 60 "tmpfs"; - options = [ "mode=0755" ]; - }; - - # Note that /dev/root is a symlink to the actual root device - # specified on the kernel command line, created in the stage 1 - # init script. - fileSystems."/iso" = - { device = "/dev/root"; - neededForBoot = true; - noCheck = true; - }; - - # In stage 1, mount a tmpfs on top of /nix/store (the squashfs - # image) to make this a live CD. - fileSystems."/nix/.ro-store" = - { fsType = "squashfs"; - device = "/iso/nix-store.squashfs"; - options = [ "loop" ]; - neededForBoot = true; - }; - - fileSystems."/nix/.rw-store" = - { fsType = "tmpfs"; - options = [ "mode=0755" ]; - neededForBoot = true; - }; - - fileSystems."/nix/store" = - { fsType = "overlay"; - device = "overlay"; - options = [ - "lowerdir=/nix/.ro-store" - "upperdir=/nix/.rw-store/store" - "workdir=/nix/.rw-store/work" - ]; - - depends = [ - "/nix/.ro-store" - "/nix/.rw-store/store" - "/nix/.rw-store/work" - ]; - }; + fileSystems = config.lib.isoFileSystems; boot.initrd.availableKernelModules = [ "squashfs" "iso9660" "uas" "overlay" ]; diff --git a/nixos/modules/installer/netboot/netboot.nix b/nixos/modules/installer/netboot/netboot.nix index f7543fdf4a2..adcaf9d1a33 100644 --- a/nixos/modules/installer/netboot/netboot.nix +++ b/nixos/modules/installer/netboot/netboot.nix @@ -29,31 +29,31 @@ with lib; then [] else [ pkgs.grub2 pkgs.syslinux ]); - fileSystems."/" = - # This module is often over-layed onto an existing host config - # that defines `/`. We use mkOverride 60 to override standard - # values, but at the same time leave room for mkForce values - # targeted at the image build. - { fsType = mkOverride 60 "tmpfs"; + # This module is often over-layed onto an existing host config + # that defines `fileSystems`. We use mkOverride 60 to override + # standard values, but at the same time leave room for mkForce + # values targeted at the image build. + fileSystems."/" = mkOverride 60 + { fsType = "tmpfs"; options = [ "mode=0755" ]; }; # In stage 1, mount a tmpfs on top of /nix/store (the squashfs # image) to make this a live CD. - fileSystems."/nix/.ro-store" = + fileSystems."/nix/.ro-store" = mkOverride 60 { fsType = "squashfs"; device = "../nix-store.squashfs"; options = [ "loop" ]; neededForBoot = true; }; - fileSystems."/nix/.rw-store" = + fileSystems."/nix/.rw-store" = mkOverride 60 { fsType = "tmpfs"; options = [ "mode=0755" ]; neededForBoot = true; }; - fileSystems."/nix/store" = + fileSystems."/nix/store" = mkOverride 60 { fsType = "overlay"; device = "overlay"; options = [ |