liminix

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

default.nix (4061B)


      1 ## Kernel-related options
      2 ## ======================
      3 ##
      4 ##
      5 
      6 { lib, pkgs, config, ...}:
      7 let
      8   inherit (lib) mkEnableOption mkOption types isDerivation hasAttr ;
      9   inherit (pkgs.pseudofile) dir symlink;
     10   inherit (pkgs.liminix.networking) address interface;
     11   inherit (pkgs.liminix.services) bundle;
     12   inherit (pkgs) liminix;
     13 
     14   type_service = pkgs.liminix.lib.types.service;
     15 
     16   mergeConditionals = conf : conditions :
     17     # for each key in conditions, if it is present in conf
     18     # then merge the associated value into conf
     19     lib.foldlAttrs
     20       (acc: name: value:
     21         if (conf ? ${name}) && (conf.${name} != "n")
     22         then acc // value
     23         else acc)
     24       conf
     25       conditions;
     26 in {
     27   options = {
     28     kernel = {
     29       src = mkOption { type = types.path; } ;
     30       version = mkOption { type = types.str; default = "5.15.137";} ;
     31       modular = mkOption {
     32         type = types.bool;
     33         default = true;
     34         description = "support loadable kernel modules";
     35       };
     36       extraPatchPhase = mkOption {
     37         default = "true";
     38         type = types.lines;
     39       };
     40       config = mkOption {
     41         description = ''
     42           Kernel config options, as listed in Kconfig* files in the
     43           kernel source tree. Do not include the leading "CONFIG_"
     44           prefix when defining these.  Most values are "y", "n" or "m",
     45           but sometimes other strings are also used.
     46         '';
     47         type = types.attrsOf types.nonEmptyStr;
     48         example = lib.literalExpression ''
     49           {
     50             BRIDGE = "y";
     51             TMPFS = "y";
     52             FW_LOADER_USER_HELPER = "n";
     53           };
     54         '';
     55       };
     56       conditionalConfig = mkOption {
     57         description = ''
     58           Kernel config options that should only be applied when
     59           some other option is present.
     60         '';
     61         type = types.attrsOf (types.attrsOf types.nonEmptyStr);
     62         default = {};
     63         example = {
     64           USB = {
     65             USB_XHCI_MVEBU = "y";
     66             USB_XHCI_HCD = "y";
     67           };
     68         };
     69       };
     70       makeTargets = mkOption {
     71         type = types.listOf types.str;
     72       };
     73     };
     74   };
     75   config = {
     76     system.outputs =
     77       let
     78         mergedConfig = mergeConditionals
     79           config.kernel.config
     80           config.kernel.conditionalConfig;
     81         k = liminix.builders.kernel.override {
     82           config = mergedConfig;
     83           inherit (config.kernel) version src extraPatchPhase;
     84           targets = config.kernel.makeTargets;
     85         };
     86       in {
     87         kernel = k.vmlinux;
     88         zimage = k.zImage;
     89       };
     90 
     91     kernel = rec {
     92       modular = true; # disabling this is not yet supported
     93       makeTargets = ["vmlinux"];
     94       config = {
     95         IKCONFIG = "y";
     96         IKCONFIG_PROC = "y";
     97         PROC_FS = "y";
     98 
     99         KEXEC = "y";
    100         MODULES = if modular then "y" else "n";
    101         MODULE_SIG = if modular then "y" else "n";
    102         DEBUG_FS = "y";
    103 
    104         # basic networking protocols
    105         NET = "y";
    106         UNIX = "y";
    107         INET = "y";
    108         IPV6 = "y";
    109         PACKET = "y";           # for ppp, tcpdump ...
    110         SYSVIPC= "y";
    111 
    112         NETDEVICES = "y";       # even PPP needs this
    113 
    114         # disabling this option causes the kernel to use an "empty"
    115         # initramfs instead: it has a /dev/console node and not much
    116         # else.  Note that pid 1 is started *before* the root
    117         # filesystem is mounted and it expects /dev/console to be
    118         # present already
    119         BLK_DEV_INITRD = lib.mkDefault "n"; # overriden by initramfs module
    120 
    121         # s6-linux-init mounts this on /dev
    122         DEVTMPFS = "y";
    123         # some or all of these may be fix for "tmpfs: Unknown parameter 'mode'" error
    124         TMPFS = "y";
    125         TMPFS_POSIX_ACL = "y";
    126         TMPFS_XATTR = "y";
    127 
    128         FW_LOADER = "y";
    129         FW_LOADER_COMPRESS = "y";
    130         # We don't have a user helper, so we get multiple 60s pauses
    131         # at boot time unless we disable trying to call it.
    132         # https://lkml.org/lkml/2013/8/5/175
    133         FW_LOADER_USER_HELPER = "n";
    134       };
    135     };
    136   };
    137 }