mirror of
https://git.sr.ht/~magic_rb/dotfiles
synced 2024-11-30 03:56:12 +01:00
5b2a0468ca
Signed-off-by: magic_rb <magic_rb@redalder.org>
91 lines
2.1 KiB
Nix
91 lines
2.1 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}: let
|
|
inherit
|
|
(lib)
|
|
mkEnableOption
|
|
mkOption
|
|
mkIf
|
|
types
|
|
concatStrings
|
|
mapAttrsToList
|
|
escapeShellArg
|
|
concatMap
|
|
;
|
|
cfg = config.boot.netboot-xyz;
|
|
|
|
grubOptions = {name, ...}: {
|
|
options.image = mkOption {
|
|
default = let
|
|
url = {
|
|
bios = {
|
|
url = "https://github.com/netbootxyz/netboot.xyz/releases/download/2.0.79/netboot.xyz.lkrn";
|
|
hash = "sha256-Jtu4ps9hVHYVJI1IKNnXHMD9QnFLwv53OWOaSt0yVWM=";
|
|
};
|
|
efi = {
|
|
url = "https://github.com/netbootxyz/netboot.xyz/releases/download/2.0.79/netboot.xyz.efi";
|
|
hash = "sha256-UvmoiHpThoj3cNR27KXydVfsPPSe2UDq5w/JmBDJFO8=";
|
|
};
|
|
};
|
|
in
|
|
pkgs.fetchurl ({
|
|
curlOptsList = ["-L"];
|
|
}
|
|
// url.${name});
|
|
};
|
|
};
|
|
in {
|
|
options.boot.netboot-xyz = {
|
|
enable = mkEnableOption "Enable netboot.xyz in grub.";
|
|
|
|
grub = mkOption {
|
|
type = types.attrTag {
|
|
bios = mkOption {
|
|
type = types.submodule grubOptions;
|
|
};
|
|
efi = mkOption {
|
|
type = types.submodule grubOptions;
|
|
};
|
|
};
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
boot.loader.grub.extraEntries =
|
|
if cfg.grub ? "efi"
|
|
then ''
|
|
menuentry "netboot.xyz.efi" {
|
|
chainloader @bootRoot@/netboot.xyz.efi
|
|
}
|
|
''
|
|
else if cfg.grub ? "bios"
|
|
then ''
|
|
menuentry "netboot.xyz.lkrn" {
|
|
linux16 @bootRoot@/netboot.xyz.lkrn
|
|
}
|
|
''
|
|
else throw cfg.grub;
|
|
|
|
boot.loader.grub.extraPrepareConfig = concatStrings (map (boot: let
|
|
file =
|
|
if cfg.grub ? "efi"
|
|
then {
|
|
name = "netboot.xyz.efi";
|
|
source = "${cfg.grub.efi.image}";
|
|
}
|
|
else if cfg.grub ? "bios"
|
|
then {
|
|
name = "netboot.xyz.lkrn";
|
|
source = "${cfg.grub.bios.image}";
|
|
}
|
|
else throw cfg.grub;
|
|
in ''
|
|
${pkgs.coreutils}/bin/install -Dp "${file.source}" "${boot.path}/"${escapeShellArg file.name}
|
|
'')
|
|
config.boot.loader.grub.mirroredBoots);
|
|
};
|
|
}
|