diff options
author | Alyssa Ross <hi@alyssa.is> | 2021-09-08 17:57:14 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2021-09-13 11:31:47 +0000 |
commit | ee7984efa14902a2ddd820c937457667a4f40c6a (patch) | |
tree | c9c1d046733cefe5e21fdd8a52104175d47b2443 /nixpkgs/nixos/modules/installer/cd-dvd | |
parent | ffc9d4ba381da62fd08b361bacd1e71e2a3d934d (diff) | |
parent | b3c692172e5b5241b028a98e1977f9fb12eeaf42 (diff) | |
download | nixlib-ee7984efa14902a2ddd820c937457667a4f40c6a.tar nixlib-ee7984efa14902a2ddd820c937457667a4f40c6a.tar.gz nixlib-ee7984efa14902a2ddd820c937457667a4f40c6a.tar.bz2 nixlib-ee7984efa14902a2ddd820c937457667a4f40c6a.tar.lz nixlib-ee7984efa14902a2ddd820c937457667a4f40c6a.tar.xz nixlib-ee7984efa14902a2ddd820c937457667a4f40c6a.tar.zst nixlib-ee7984efa14902a2ddd820c937457667a4f40c6a.zip |
Merge commit 'b3c692172e5b5241b028a98e1977f9fb12eeaf42'
Diffstat (limited to 'nixpkgs/nixos/modules/installer/cd-dvd')
-rw-r--r-- | nixpkgs/nixos/modules/installer/cd-dvd/installation-cd-base.nix | 5 | ||||
-rw-r--r-- | nixpkgs/nixos/modules/installer/cd-dvd/iso-image.nix | 94 |
2 files changed, 55 insertions, 44 deletions
diff --git a/nixpkgs/nixos/modules/installer/cd-dvd/installation-cd-base.nix b/nixpkgs/nixos/modules/installer/cd-dvd/installation-cd-base.nix index aecb65b8c576..618057618d0c 100644 --- a/nixpkgs/nixos/modules/installer/cd-dvd/installation-cd-base.nix +++ b/nixpkgs/nixos/modules/installer/cd-dvd/installation-cd-base.nix @@ -30,6 +30,11 @@ with lib; # Add Memtest86+ to the CD. boot.loader.grub.memtest86.enable = true; + # An installation media cannot tolerate a host config defined file + # system layout on a fresh machine, before it has been formatted. + swapDevices = mkImageMediaOverride [ ]; + fileSystems = mkImageMediaOverride config.lib.isoFileSystems; + boot.postBootCommands = '' for o in $(</proc/cmdline); do case "$o" in diff --git a/nixpkgs/nixos/modules/installer/cd-dvd/iso-image.nix b/nixpkgs/nixos/modules/installer/cd-dvd/iso-image.nix index d94af0b5bf74..78cbf14bbaf6 100644 --- a/nixpkgs/nixos/modules/installer/cd-dvd/iso-image.nix +++ b/nixpkgs/nixos/modules/installer/cd-dvd/iso-image.nix @@ -615,53 +615,19 @@ in }; - config = { - assertions = [ + # store them in lib so we can mkImageMediaOverride the + # entire file system layout in installation media (only) + config.lib.isoFileSystems = { + "/" = mkImageMediaOverride { - assertion = !(stringLength config.isoImage.volumeID > 32); - # https://wiki.osdev.org/ISO_9660#The_Primary_Volume_Descriptor - # Volume Identifier can only be 32 bytes - message = let - length = stringLength config.isoImage.volumeID; - howmany = toString length; - toomany = toString (length - 32); - in - "isoImage.volumeID ${config.isoImage.volumeID} is ${howmany} characters. That is ${toomany} characters longer than the limit of 32."; - } - ]; - - boot.loader.grub.version = 2; - - # Don't build the GRUB menu builder script, since we don't need it - # here and it causes a cyclic dependency. - boot.loader.grub.enable = false; - - environment.systemPackages = [ grubPkgs.grub2 grubPkgs.grub2_efi ] - ++ optional canx86BiosBoot pkgs.syslinux - ; - - # In stage 1 of the boot, mount the CD as the root FS by label so - # that we don't need to know its device. We pass the label of the - # root filesystem on the kernel command line, rather than in - # `fileSystems' below. This allows CD-to-USB converters such as - # UNetbootin to rewrite the kernel command line to pass the label or - # UUID of the USB stick. It would be nicer to write - # `root=/dev/disk/by-label/...' here, but UNetbootin doesn't - # recognise that. - boot.kernelParams = - [ "root=LABEL=${config.isoImage.volumeID}" - "boot.shell_on_fail" - ]; - - fileSystems."/" = - { fsType = "tmpfs"; + 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. - fileSystems."/iso" = + "/iso" = mkImageMediaOverride { device = "/dev/root"; neededForBoot = true; noCheck = true; @@ -669,20 +635,20 @@ in # In stage 1, mount a tmpfs on top of /nix/store (the squashfs # image) to make this a live CD. - fileSystems."/nix/.ro-store" = + "/nix/.ro-store" = mkImageMediaOverride { fsType = "squashfs"; device = "/iso/nix-store.squashfs"; options = [ "loop" ]; neededForBoot = true; }; - fileSystems."/nix/.rw-store" = + "/nix/.rw-store" = mkImageMediaOverride { fsType = "tmpfs"; options = [ "mode=0755" ]; neededForBoot = true; }; - fileSystems."/nix/store" = + "/nix/store" = mkImageMediaOverride { fsType = "overlay"; device = "overlay"; options = [ @@ -690,13 +656,53 @@ in "upperdir=/nix/.rw-store/store" "workdir=/nix/.rw-store/work" ]; - depends = [ "/nix/.ro-store" "/nix/.rw-store/store" "/nix/.rw-store/work" ]; }; + }; + + config = { + assertions = [ + { + assertion = !(stringLength config.isoImage.volumeID > 32); + # https://wiki.osdev.org/ISO_9660#The_Primary_Volume_Descriptor + # Volume Identifier can only be 32 bytes + message = let + length = stringLength config.isoImage.volumeID; + howmany = toString length; + toomany = toString (length - 32); + in + "isoImage.volumeID ${config.isoImage.volumeID} is ${howmany} characters. That is ${toomany} characters longer than the limit of 32."; + } + ]; + + boot.loader.grub.version = 2; + + # Don't build the GRUB menu builder script, since we don't need it + # here and it causes a cyclic dependency. + boot.loader.grub.enable = false; + + environment.systemPackages = [ grubPkgs.grub2 grubPkgs.grub2_efi ] + ++ optional canx86BiosBoot pkgs.syslinux + ; + + # In stage 1 of the boot, mount the CD as the root FS by label so + # that we don't need to know its device. We pass the label of the + # root filesystem on the kernel command line, rather than in + # `fileSystems' below. This allows CD-to-USB converters such as + # UNetbootin to rewrite the kernel command line to pass the label or + # UUID of the USB stick. It would be nicer to write + # `root=/dev/disk/by-label/...' here, but UNetbootin doesn't + # recognise that. + boot.kernelParams = + [ "root=LABEL=${config.isoImage.volumeID}" + "boot.shell_on_fail" + ]; + + fileSystems = config.lib.isoFileSystems; boot.initrd.availableKernelModules = [ "squashfs" "iso9660" "uas" "overlay" ]; |