extlinux.nix (1137B)
1 { 2 config 3 , pkgs 4 , lib 5 , ... 6 }: 7 let 8 inherit (lib) mkIf mkEnableOption mkOption types concatStringsSep; 9 inherit (pkgs.pseudofile) dir symlink; 10 cfg = config.boot.loader.extlinux; 11 o = config.system.outputs; 12 cmdline = concatStringsSep " " config.boot.commandLine; 13 wantsDtb = config.hardware.dts ? src && config.hardware.dts.src != null; 14 in { 15 options.system.outputs.extlinux = mkOption { 16 type = types.package; 17 # description = ""; 18 }; 19 options.boot.loader.extlinux.enable = mkEnableOption "extlinux"; 20 21 config = mkIf cfg.enable { 22 system.outputs.extlinux = pkgs.runCommand "extlinux" {} '' 23 mkdir $out 24 cd $out 25 ${if wantsDtb then "cp ${o.dtb} dtb" else "true"} 26 cp ${o.initramfs} initramfs 27 cp ${o.zimage} kernel 28 mkdir extlinux 29 cat > extlinux/extlinux.conf << _EOF 30 menu title Liminix 31 timeout 40 32 label Liminix 33 kernel /boot/kernel 34 # initrd /boot/initramfs 35 append ${cmdline} 36 ${if wantsDtb then "fdt /boot/dtb" else ""} 37 _EOF 38 ''; 39 filesystem = dir { 40 boot = symlink config.system.outputs.extlinux; 41 }; 42 }; 43 }