liminix

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

outputs.nix (3652B)


      1 {
      2   config,
      3   pkgs,
      4   lib,
      5   ...
      6 }:
      7 let
      8   inherit (lib) mkOption types concatStringsSep;
      9   inherit (pkgs) liminix writeText;
     10   o = config.system.outputs;
     11 in
     12 {
     13   imports = [
     14     ./outputs/boot-extlinux.nix
     15     ./outputs/boot-fit.nix
     16     ./outputs/btrfs.nix
     17     ./outputs/jffs2.nix
     18     # ./outputs/mtdimage.nix
     19     ./outputs/squashfs.nix
     20     ./outputs/ubimage.nix
     21     ./outputs/uimage.nix
     22     ./outputs/updater
     23     ./outputs/vmroot.nix
     24   ];
     25   options = {
     26     system.outputs = {
     27       # the convention here is to mark an output as "internal" if
     28       # it's not a complete system (kernel plus userland, or installer)
     29       # but only part of one.
     30       kernel = mkOption {
     31         type = types.package;
     32         internal = true;
     33         description = ''
     34           kernel
     35           ******
     36 
     37           Kernel package (multi-output derivation)
     38         '';
     39       };
     40       dtb = mkOption {
     41         type = types.package;
     42         internal = true;
     43         description = ''
     44           dtb
     45           ***
     46 
     47           Compiled device tree (FDT) for the target device
     48         '';
     49       };
     50       tplink-safeloader = mkOption {
     51         type = types.package;
     52       };
     53       u-boot = mkOption {
     54         type = types.package;
     55       };
     56       manifest = mkOption {
     57         type = types.package;
     58         internal = true;
     59         description = ''
     60           Debugging aid. JSON rendition of config.filesystem, on
     61           which can run "nix-store -q --tree" on it and find
     62           out what's in the image, which is nice if it's unexpectedly huge
     63         '';
     64       };
     65       rootdir = mkOption {
     66         type = types.package;
     67         internal = true;
     68         description = ''
     69           directory of files to package into root filesystem
     70         '';
     71       };
     72       bootfiles = mkOption {
     73         type = types.nullOr types.package;
     74         internal = true;
     75         default = null;
     76         # description = "";
     77       };
     78       bootablerootdir = mkOption {
     79         type = types.package;
     80         internal = true;
     81         description = ''
     82           directory of files to package into root filesystem, including
     83           a kernel and appropriate associated gubbins for the
     84           selected bootloader
     85         '';
     86       };
     87       rootfs = mkOption {
     88         type = types.package;
     89         internal = true;
     90         description = ''
     91           root filesystem (squashfs or jffs2) image
     92         '';
     93       };
     94     };
     95   };
     96   config = {
     97     system.outputs = rec {
     98       dtb = liminix.builders.dtb {
     99         inherit (config.boot) commandLine;
    100         dts = [ config.hardware.dts.src ] ++ config.hardware.dts.includes;
    101         includes = config.hardware.dts.includePaths ++ [
    102           "${o.kernel.headers}/include"
    103         ];
    104       };
    105       rootdir =
    106         let
    107           inherit (pkgs.pkgsBuildBuild) runCommand;
    108         in
    109         runCommand "mktree" { } ''
    110           mkdir -p $out/nix/store/ $out/secrets $out/boot
    111           cp ${o.systemConfiguration}/bin/activate $out/activate
    112           ln -s ${pkgs.s6-init-bin}/bin/init $out/init
    113           mkdir -p $out/nix/store
    114           for path in $(cat ${o.systemConfiguration}/etc/nix-store-paths) ; do
    115             (cd $out && cp -a $path .$path)
    116           done
    117         '';
    118       bootablerootdir =
    119         let
    120           inherit (pkgs.pkgsBuildBuild) runCommand;
    121         in
    122         runCommand "add-slash-boot" { } ''
    123           cp -a ${o.rootdir} $out
    124           ${
    125             if o.bootfiles != null then
    126               "(cd $out && chmod -R +w . && rmdir boot && cp -a ${o.bootfiles} boot)"
    127             else
    128               ""
    129           }
    130         '';
    131       manifest = writeText "manifest.json" (builtins.toJSON config.filesystem.contents);
    132     };
    133   };
    134 }