2014-12-02 11:46:45 -05:00
|
|
|
# This module adds a scripted iPXE entry to the GRUB boot menu.
|
|
|
|
|
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
scripts = builtins.attrNames config.boot.loader.grub.ipxe;
|
|
|
|
|
|
|
|
grubEntry = name: ''
|
|
|
|
menuentry "iPXE - ${name}" {
|
|
|
|
linux16 @bootRoot@/ipxe.lkrn
|
|
|
|
initrd16 @bootRoot@/${name}.ipxe
|
|
|
|
}
|
|
|
|
|
|
|
|
'';
|
|
|
|
|
|
|
|
scriptFile =
|
|
|
|
name:
|
|
|
|
let
|
|
|
|
value = builtins.getAttr name config.boot.loader.grub.ipxe;
|
|
|
|
in
|
|
|
|
if builtins.typeOf value == "path" then value else builtins.toFile "${name}.ipxe" value;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
boot.loader.grub.ipxe = mkOption {
|
|
|
|
type = types.attrsOf (types.either types.path types.str);
|
|
|
|
description = ''
|
|
|
|
Set of iPXE scripts available for
|
|
|
|
booting from the GRUB boot menu.
|
|
|
|
'';
|
|
|
|
default = { };
|
2021-10-03 18:06:03 +02:00
|
|
|
example = literalExpression ''
|
2014-12-02 11:46:45 -05:00
|
|
|
{ demo = '''
|
|
|
|
#!ipxe
|
|
|
|
dhcp
|
|
|
|
chain http://boot.ipxe.org/demo/boot.php
|
|
|
|
''';
|
2016-01-17 19:34:55 +01:00
|
|
|
}
|
2014-12-02 11:46:45 -05:00
|
|
|
'';
|
|
|
|
};
|
2024-12-10 20:27:17 +01:00
|
|
|
};
|
2014-12-02 11:46:45 -05:00
|
|
|
|
|
|
|
config = mkIf (builtins.length scripts != 0) {
|
|
|
|
|
2022-04-04 17:54:14 +01:00
|
|
|
boot.loader.grub.extraEntries = toString (map grubEntry scripts);
|
2014-12-02 11:46:45 -05:00
|
|
|
|
|
|
|
boot.loader.grub.extraFiles =
|
|
|
|
{
|
|
|
|
"ipxe.lkrn" = "${pkgs.ipxe}/ipxe.lkrn";
|
|
|
|
}
|
|
|
|
// builtins.listToAttrs (
|
|
|
|
map (name: {
|
|
|
|
name = name + ".ipxe";
|
|
|
|
value = scriptFile name;
|
|
|
|
}) scripts
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|