-
-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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/systemd-boot: Add mirroredBoots #246897
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ let | |
|
||
python3 = pkgs.python3.withPackages (ps: [ ps.packaging ]); | ||
|
||
systemdBootBuilder = pkgs.substituteAll { | ||
systemdBootBuilder = mountPoint: pkgs.substituteAll { | ||
src = ./systemd-boot-builder.py; | ||
|
||
isExecutable = true; | ||
|
@@ -28,7 +28,9 @@ let | |
|
||
inherit (cfg) consoleMode graceful; | ||
|
||
inherit (efi) efiSysMountPoint canTouchEfiVariables; | ||
inherit (efi) canTouchEfiVariables; | ||
|
||
inherit mountPoint; | ||
|
||
inherit (config.system.nixos) distroName; | ||
|
||
|
@@ -40,33 +42,38 @@ let | |
empty_file=$(${pkgs.coreutils}/bin/mktemp) | ||
|
||
${concatStrings (mapAttrsToList (n: v: '' | ||
${pkgs.coreutils}/bin/install -Dp "${v}" "${efi.efiSysMountPoint}/"${escapeShellArg n} | ||
${pkgs.coreutils}/bin/install -D $empty_file "${efi.efiSysMountPoint}/efi/nixos/.extra-files/"${escapeShellArg n} | ||
${pkgs.coreutils}/bin/install -Dp "${v}" "${mountPoint}/"${escapeShellArg n} | ||
${pkgs.coreutils}/bin/install -D $empty_file "${mountPoint}/efi/nixos/.extra-files/"${escapeShellArg n} | ||
'') cfg.extraFiles)} | ||
|
||
${concatStrings (mapAttrsToList (n: v: '' | ||
${pkgs.coreutils}/bin/install -Dp "${pkgs.writeText n v}" "${efi.efiSysMountPoint}/loader/entries/"${escapeShellArg n} | ||
${pkgs.coreutils}/bin/install -D $empty_file "${efi.efiSysMountPoint}/efi/nixos/.extra-files/loader/entries/"${escapeShellArg n} | ||
${pkgs.coreutils}/bin/install -Dp "${pkgs.writeText n v}" "${mountPoint}/loader/entries/"${escapeShellArg n} | ||
${pkgs.coreutils}/bin/install -D $empty_file "${mountPoint}/efi/nixos/.extra-files/loader/entries/"${escapeShellArg n} | ||
'') cfg.extraEntries)} | ||
''; | ||
}; | ||
|
||
checkedSystemdBootBuilder = pkgs.runCommand "systemd-boot" { | ||
checkedSystemdBootBuilder = mountPoint: pkgs.runCommand "systemd-boot" { | ||
nativeBuildInputs = [ pkgs.mypy python3 ]; | ||
} '' | ||
install -m755 ${systemdBootBuilder} $out | ||
install -m755 ${systemdBootBuilder mountPoint} $out | ||
mypy \ | ||
--no-implicit-optional \ | ||
--disallow-untyped-calls \ | ||
--disallow-untyped-defs \ | ||
$out | ||
''; | ||
|
||
finalSystemdBootBuilder = pkgs.writeScript "install-systemd-boot.sh" '' | ||
#!${pkgs.runtimeShell} | ||
${checkedSystemdBootBuilder} "$@" | ||
${cfg.extraInstallCommands} | ||
''; | ||
finalSystemdBootBuilder = let | ||
installDirs = | ||
if cfg.mirroredBoots != [] | ||
then cfg.mirroredBoots | ||
else [efi.efiSysMountPoint]; | ||
in | ||
pkgs.writeShellScript "install-systemd-boot.sh" | ||
(lib.concatMapStrings (x: "${checkedSystemdBootBuilder x} \"$@\"\n") installDirs) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that, like in grub.nix, the usual error detection Why keeping on passing Nitpick: here each mountpoint generates a new derivation, the mountpoint could instead be passed as an envvar |
||
+ cfg.extraInstallCommands; | ||
|
||
in { | ||
|
||
imports = | ||
|
@@ -238,6 +245,17 @@ in { | |
''; | ||
}; | ||
|
||
mirroredBoots = lib.mkOption { | ||
type = lib.types.listOf lib.types.str; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
default = []; | ||
example = '' | ||
[ "/boot1" "/boot2" ] | ||
''; | ||
description = lib.mdDoc '' | ||
Mirror the boot configuration to multiple locations. | ||
''; | ||
}; | ||
|
||
}; | ||
|
||
config = mkIf cfg.enable { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My first thought was that mirroredBoots should be additional mountpoints, but seeing this I guess the implementation is only these mountpoints (the "main" ESP mountpoint gets ignored)? Am I the only one that find that surprising?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, and AFAIU the
grub.nix
case,mirroredBoots
are additionals mountpoints there:nixpkgs/nixos/modules/system/boot/loader/grub/grub.nix
Lines 708 to 710 in ec6cc9c