diff options
author | Markus Partheymueller <markus.partheymueller@cyberus-technology.de> | 2022-11-14 14:20:58 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-14 14:20:58 +0100 |
commit | 5bc1b01a403e071500a3b0659364fb6ee20391e1 (patch) | |
tree | 9ecaa1e7845d1966b89f5c85172be71932a28cd0 | |
parent | b60aa0e01ceaa923c6a09089d42469dab43e70c4 (diff) |
boot.loader.systemd-boot: add extraInstallCommands option (#200715)
-rw-r--r-- | nixos/modules/system/boot/loader/systemd-boot/systemd-boot.nix | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/nixos/modules/system/boot/loader/systemd-boot/systemd-boot.nix b/nixos/modules/system/boot/loader/systemd-boot/systemd-boot.nix index a9d43d027e011..8cb7c7b8e47bb 100644 --- a/nixos/modules/system/boot/loader/systemd-boot/systemd-boot.nix +++ b/nixos/modules/system/boot/loader/systemd-boot/systemd-boot.nix @@ -57,6 +57,12 @@ let --disallow-untyped-defs \ $out ''; + + finalSystemdBootBuilder = pkgs.writeScript "install-systemd-boot.sh" '' + #!${pkgs.runtimeShell} + ${checkedSystemdBootBuilder} "$@" + ${cfg.extraInstallCommands} + ''; in { imports = @@ -99,6 +105,22 @@ in { ''; }; + extraInstallCommands = mkOption { + default = ""; + example = '' + default_cfg=$(cat /boot/loader/loader.conf | grep default | awk '{print $2}') + init_value=$(cat /boot/loader/entries/$default_cfg | grep init= | awk '{print $2}') + sed -i "s|@INIT@|$init_value|g" /boot/custom/config_with_placeholder.conf + ''; + type = types.lines; + description = lib.mdDoc '' + Additional shell commands inserted in the bootloader installer + script after generating menu entries. It can be used to expand + on extra boot entries that cannot incorporate certain pieces of + information (such as the resulting `init=` kernel parameter). + ''; + }; + consoleMode = mkOption { default = "keep"; @@ -277,7 +299,7 @@ in { ]; system = { - build.installBootLoader = checkedSystemdBootBuilder; + build.installBootLoader = finalSystemdBootBuilder; boot.loader.id = "systemd-boot"; |