nixpkgs/nixos/modules/installer/cd-dvd/installation-cd-base.nix
Michael Hoang 3aed2ac768 nixos/installation-cd-base: fix installer expecting LUKS devices
If we create an installer based on a configuration that uses LUKS and we try to
boot it on an unformatted machine, it will fail waiting for the LUKS device to
appear.

We override `boot.initrd.luks.devices` like the `qemu-vm` module to solve this issue:

f23e0d855a/nixos/modules/virtualisation/qemu-vm.nix (L1407-L1408)
2025-07-17 15:18:52 +10:00

58 lines
1.3 KiB
Nix

# This module contains the basic configuration for building a NixOS
# installation CD.
{
config,
lib,
options,
pkgs,
...
}:
{
imports = [
./iso-image.nix
# Profiles of this basic installation CD.
../../profiles/base.nix
../../profiles/installation-device.nix
];
hardware.enableAllHardware = true;
# Adds terminus_font for people with HiDPI displays
console.packages = options.console.packages.default ++ [ pkgs.terminus_font ];
# EFI booting
isoImage.makeEfiBootable = true;
# USB booting
isoImage.makeUsbBootable = true;
# 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 = lib.mkImageMediaOverride [ ];
fileSystems = lib.mkImageMediaOverride config.lib.isoFileSystems;
boot.initrd.luks.devices = lib.mkImageMediaOverride { };
boot.postBootCommands = ''
for o in $(</proc/cmdline); do
case "$o" in
live.nixos.passwd=*)
set -- $(IFS==; echo $o)
echo "nixos:$2" | ${pkgs.shadow}/bin/chpasswd
;;
esac
done
'';
environment.defaultPackages = with pkgs; [
rsync
];
programs.git.enable = lib.mkDefault true;
system.stateVersion = lib.mkDefault lib.trivial.release;
}