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