forked from dan/liminix
1
0
Fork 0
liminix/modules/outputs/extlinux.nix

44 lines
1.1 KiB
Nix
Raw Normal View History

2023-12-02 15:31:55 +00:00
{
config
, pkgs
, lib
, ...
}:
let
inherit (lib) mkIf mkEnableOption mkOption types concatStringsSep;
inherit (pkgs.pseudofile) dir symlink;
2023-12-02 15:31:55 +00:00
cfg = config.boot.loader.extlinux;
o = config.system.outputs;
cmdline = concatStringsSep " " config.boot.commandLine;
wantsDtb = config.hardware.dts ? src && config.hardware.dts.src != null;
2023-12-02 15:31:55 +00:00
in {
options.system.outputs.extlinux = mkOption {
type = types.package;
# description = "";
};
options.boot.loader.extlinux.enable = mkEnableOption "extlinux";
config = mkIf cfg.enable {
2023-12-02 15:31:55 +00:00
system.outputs.extlinux = pkgs.runCommand "extlinux" {} ''
mkdir $out
cd $out
${if wantsDtb then "cp ${o.dtb} dtb" else "true"}
cp ${o.initramfs} initramfs
2024-02-02 19:43:34 +00:00
cp ${o.zimage} kernel
mkdir extlinux
cat > extlinux/extlinux.conf << _EOF
2023-12-02 15:31:55 +00:00
menu title Liminix
timeout 40
2023-12-02 15:31:55 +00:00
label Liminix
kernel /boot/kernel
# initrd /boot/initramfs
2024-01-07 20:30:23 +00:00
append ${cmdline}
${if wantsDtb then "fdt /boot/dtb" else ""}
2023-12-02 15:31:55 +00:00
_EOF
'';
filesystem = dir {
boot = symlink config.system.outputs.extlinux;
};
2023-12-02 15:31:55 +00:00
};
}