···
···
# specified on the kernel command line, created in the stage 1
"/iso" = lib.mkImageMediaOverride {
+
if config.boot.initrd.systemd.enable then
+
"/dev/disk/by-label/${config.isoImage.volumeID}"
···
# image) to make this a live CD.
"/nix/.ro-store" = lib.mkImageMediaOverride {
+
device = "${lib.optionalString config.boot.initrd.systemd.enable "/sysroot"}/iso/nix-store.squashfs";
···
"/nix/store" = lib.mkImageMediaOverride {
+
lowerdir = [ "/nix/.ro-store" ];
+
upperdir = "/nix/.rw-store/store";
+
workdir = "/nix/.rw-store/work";
···
# UUID of the USB stick. It would be nicer to write
# `root=/dev/disk/by-label/...' here, but UNetbootin doesn't
+
boot.kernelParams = lib.optionals (!config.boot.initrd.systemd.enable) [
+
"root=LABEL=${config.isoImage.volumeID}"
fileSystems = config.lib.isoFileSystems;
···
+
boot.initrd.systemd = lib.mkIf config.boot.initrd.systemd.enable {
+
emergencyAccess = true;
+
# Most of util-linux is not included by default.
+
initrdBin = [ config.boot.initrd.systemd.package.util-linux ];
+
description = "Copy ISO contents to RAM";
+
requiredBy = [ "initrd.target" ];
+
"${utils.escapeSystemdPath "/sysroot/nix/.ro-store"}.mount"
+
"initrd-switch-root.target"
+
RequiresMountsFor = "/sysroot/iso";
+
ConditionKernelCommandLine = "copytoram";
+
RemainAfterExit = true;
+
config.boot.initrd.systemd.package.util-linux
+
device=$(findmnt -n -o SOURCE --target /sysroot/iso)
+
fsSize=$(blockdev --getsize64 "$device" || stat -Lc '%s' "$device")
+
mount --bind --make-private /sysroot/iso /tmp-iso
+
mount -t tmpfs -o size="$fsSize" tmpfs /sysroot/iso
+
cp -r /tmp-iso/* /sysroot/iso/
# Closures to be copied to the Nix store on the CD, namely the init
# script and the top-level system configuration directory.
isoImage.storeContents = [
···
source = config.isoImage.efiSplashImage;
target = "/EFI/BOOT/efi-background.png";
+
++ lib.optionals (config.isoImage.makeEfiBootable && !config.boot.initrd.systemd.enable) [
+
# http://www.supergrubdisk.org/wiki/Loopback.cfg
+
# This feature will be removed, and thus is not supported by systemd initrd
+
source = (pkgs.writeTextDir "grub/loopback.cfg" "source /EFI/BOOT/grub.cfg") + "/grub";
++ lib.optionals (config.boot.loader.grub.memtest86.enable && config.isoImage.makeBiosBootable) [