liminix

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

boot-extlinux.nix (1295B)


      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   bootFilesName = builtins.unsafeDiscardStringContext
     19     # in this situation, perfectly safe to discard the context as the
     20     # attrset _value_ names the same derivation
     21     (builtins.baseNameOf config.system.outputs.bootfiles);
     22 in
     23 {
     24   options.boot.loader.extlinux.enable = mkEnableOption "extlinux";
     25 
     26   config = mkIf cfg.enable {
     27     system.outputs.bootfiles = pkgs.runCommand "extlinux" { } ''
     28       mkdir $out
     29       cd $out
     30       ${if wantsDtb then "cp ${o.dtb} dtb" else "true"}
     31       cp ${o.initramfs} initramfs
     32       cp ${o.kernel.zImage} kernel
     33       mkdir extlinux
     34       cat > extlinux/extlinux.conf << _EOF
     35       menu title Liminix
     36       timeout 40
     37       label Liminix
     38         kernel /boot/kernel
     39         # initrd /boot/initramfs
     40         append ${cmdline} 
     41         ${if wantsDtb then "fdt /boot/dtb" else ""}
     42       _EOF
     43     '';
     44     filesystem = dir {
     45       "${bootFilesName}" = symlink config.system.outputs.bootfiles;
     46     };
     47   };
     48 }