git.iko.soy/typeable/nixpkgs
on master help sign in
boot.loader.grub: add extraInstallCommands option
commit771ba47d564b734ac7644c19032b19a95a9e840e authorGauvain 'GovanifY' Roussel-Tarbouriech <gauvain@govanify.com> dateSat 2 Jan 2021, 18:23 (6 years ago) parent071eb8b
1 file changed+21−1
nixos/modules/system/boot/loader/grub/grub.nix+21−1
nixos/modules/system/boot/loader/grub/grub.nix+21−1
@@ -327,6 +327,26 @@ in
327327 '';
328328 };
329329
330+ extraInstallCommands = mkOption {
331+ default = "";
332+ example = literalExample ''
333+ # the example below generates detached signatures that GRUB can verify
334+ # https://www.gnu.org/software/grub/manual/grub/grub.html#Using-digital-signatures
335+ ''${pkgs.findutils}/bin/find /boot -not -path "/boot/efi/*" -type f -name '*.sig' -delete
336+ old_gpg_home=$GNUPGHOME
337+ export GNUPGHOME="$(mktemp -d)"
338+ ''${pkgs.gnupg}/bin/gpg --import ''${priv_key} > /dev/null 2>&1
339+ ''${pkgs.findutils}/bin/find /boot -not -path "/boot/efi/*" -type f -exec ''${pkgs.gnupg}/bin/gpg --detach-sign "{}" \; > /dev/null 2>&1
340+ rm -rf $GNUPGHOME
341+ export GNUPGHOME=$old_gpg_home
342+ '';
343+ type = types.lines;
344+ description = ''
345+ Additional shell commands inserted in the bootloader installer
346+ script after generating menu entries.
347+ '';
348+ };
349+
330350 extraPerEntryConfig = mkOption {
331351 default = "";
332352 example = "root (hd0)";
@@ -715,7 +735,7 @@ in
715735 ${optionalString cfg.enableCryptodisk "export GRUB_ENABLE_CRYPTODISK=y"}
716736 '' + flip concatMapStrings cfg.mirroredBoots (args: ''
717737 ${pkgs.perl}/bin/perl ${install-grub-pl} ${grubConfig args} $@
718− ''));
738+ '') + cfg.extraInstallCommands);
719739
720740 system.build.grub = grub;
721741