Skip to content

Commit

Permalink
nixos/grub: add option to use install-grub-ng
Browse files Browse the repository at this point in the history
  • Loading branch information
pluiedev committed Jun 6, 2024
1 parent 57b3a02 commit 6490219
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions nixos/modules/system/boot/loader/grub/grub.nix
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,14 @@ in
'';
};

useInstallNg = mkOption {
default = false;
type = types.bool;
description = ''
Whether to use `install-grub-ng`, an experimental rewrite of `install-grub`
in Rust, with the goal of replacing the original Perl script.
'';
};
};

};
Expand Down Expand Up @@ -738,13 +746,23 @@ in
XMLLibXML XMLSAX XMLSAXBase
ListCompare JSON
]);
in pkgs.writeScript "install-grub.sh" (''
#!${pkgs.runtimeShell}
set -e
${optionalString cfg.enableCryptodisk "export GRUB_ENABLE_CRYPTODISK=y"}
'' + flip concatMapStrings cfg.mirroredBoots (args: ''
${perl}/bin/perl ${install-grub-pl} ${grubConfig args} $@
'') + cfg.extraInstallCommands);
ng = pkgs.install-grub-ng.override {
inherit (config.system.nixos) distroName;
};
genRun = args: if cfg.useInstallNg then
"${lib.getExe ng} ${grubConfig args} $@\n"
else
"${lib.getExe perl} ${install-grub-pl} ${grubConfig args} $@\n";
in
pkgs.writeScript "install-grub.sh" (
''
#!${pkgs.runtimeShell}
set -e
${optionalString cfg.enableCryptodisk "export GRUB_ENABLE_CRYPTODISK=y"}
''
+ flip concatMapStrings cfg.mirroredBoots genRun
+ cfg.extraInstallCommands
);

system.build.grub = grub;

Expand Down

0 comments on commit 6490219

Please sign in to comment.