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