liminix

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

boot-extlinux.nix (1073B)


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