Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos/iso-image: improved grub and media config #279994

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 58 additions & 3 deletions nixos/modules/installer/cd-dvd/iso-image.nix
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,18 @@ let
echo "If you see this message, your EFI system doesn't support this feature."
echo ""
}

${lib.concatStrings
(
map
({name, class, body}: ''
menuentry '${name}' --class ${class} {
${body}
}
'')
config.isoImage.grubExtraMenus
)}

menuentry 'Shutdown' --class shutdown {
halt
}
Expand All @@ -443,6 +455,16 @@ let
mkdir -p ./EFI/BOOT
cp -rp "${efiDir}"/EFI/BOOT/{grub.cfg,*.EFI,*.efi} ./EFI/BOOT

${lib.concatStrings
(
map
({source, target}: ''
mkdir -p ./`dirname ./${target}`
cp -rp ${source} ./${target}
'')
config.isoImage.bootContents
)}

# Rewrite dates for everything in the FS
find . -exec touch --date=2000-01-01 {} +

Expand All @@ -459,11 +481,11 @@ let
mkfs.vfat --invariant -i 12345678 -n EFIBOOT "$out"

# Force a fixed order in mcopy for better determinism, and avoid file globbing
for d in $(find EFI -type d | sort); do
for d in $(find -type d | tail -n +2 | sort); do
faketime "2000-01-01 00:00:00" mmd -i "$out" "::/$d"
done

for f in $(find EFI -type f | sort); do
for f in $(find -type f | sort); do
mcopy -pvm -i "$out" "$f" "::/$f"
done

Expand Down Expand Up @@ -540,7 +562,20 @@ in
'';
description = ''
This option lists files to be copied to fixed locations in the
generated ISO image.
main data partition of the generated ISO image.
'';
};

isoImage.bootContents = lib.mkOption {
default = [];
example = lib.literalExpression ''
misuzu marked this conversation as resolved.
Show resolved Hide resolved
[ { source = ./your-custom-efi-app.efi;
target = "EFI/boot/your-custom-efi-app.efi";
} ]
'';
description = ''
This option lists files to be copied to fixed locations in the
El-Torito boot catalog.
'';
};

Expand Down Expand Up @@ -626,6 +661,26 @@ in
'';
};

isoImage.grubExtraMenus = lib.mkOption {
default = [];
type = lib.types.listOf (lib.types.submodule {
options.name = lib.mkOption {
description = "Label of the option on the GRUB menu.";
type = lib.types.str;
};

options.class = lib.mkOption {
description = "Class of the option in the GRUB menu (i.e. `settings`)";
type = lib.types.str;
};

options.body = lib.mkOption {
description = "GRUB script to be executed when the option is selected";
type = lib.types.str;
};
});
};

isoImage.syslinuxTheme = lib.mkOption {
default = ''
MENU TITLE ${config.system.nixos.distroName}
Expand Down
Loading