liminix

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

kernel.nix (3119B)


      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 in {
     17   options = {
     18     kernel = {
     19       src = mkOption { type = types.path; } ;
     20       modular = mkOption {
     21         type = types.bool;
     22         default = true;
     23         description = "support loadable kernel modules";
     24       };
     25       extraPatchPhase = mkOption {
     26         default = "true";
     27         type = types.lines;
     28       };
     29       config = mkOption {
     30         description = ''
     31           Kernel config options, as listed in Kconfig* files in the
     32           kernel source tree. Do not include the leading "CONFIG_"
     33           prefix when defining these.  Most values are "y", "n" or "m",
     34           but sometimes other strings are also used.
     35         '';
     36         type = types.attrsOf types.nonEmptyStr;
     37         example = lib.literalExpression ''
     38           {
     39             BRIDGE = "y";
     40             TMPFS = "y";
     41             FW_LOADER_USER_HELPER = "n";
     42           };
     43         '';
     44       };
     45       makeTargets = mkOption {
     46         type = types.listOf types.str;
     47       };
     48     };
     49   };
     50   config = {
     51     system.outputs =
     52       let k = liminix.builders.kernel.override {
     53             inherit (config.kernel) config src extraPatchPhase;
     54             targets = config.kernel.makeTargets;
     55           };
     56       in {
     57         kernel = k.vmlinux;
     58         zimage = k.zImage;
     59       };
     60 
     61     kernel = rec {
     62       modular = true; # disabling this is not yet supported
     63       makeTargets = ["vmlinux"];
     64       config = {
     65         IKCONFIG = "y";
     66         IKCONFIG_PROC = "y";
     67         PROC_FS = "y";
     68 
     69         KEXEC = "y";
     70         MODULES = if modular then "y" else "n";
     71         MODULE_SIG = if modular then "y" else "n";
     72         DEBUG_FS = "y";
     73 
     74         # basic networking protocols
     75         NET = "y";
     76         UNIX = "y";
     77         INET = "y";
     78         IPV6 = "y";
     79         PACKET = "y";           # for ppp, tcpdump ...
     80         SYSVIPC= "y";
     81 
     82         NETDEVICES = "y";       # even PPP needs this
     83 
     84         # disabling this option causes the kernel to use an "empty"
     85         # initramfs instead: it has a /dev/console node and not much
     86         # else.  Note that pid 1 is started *before* the root
     87         # filesystem is mounted and it expects /dev/console to be
     88         # present already
     89         BLK_DEV_INITRD = lib.mkDefault "n"; # overriden by initramfs module
     90 
     91         # s6-linux-init mounts this on /dev
     92         DEVTMPFS = "y";
     93         # some or all of these may be fix for "tmpfs: Unknown parameter 'mode'" error
     94         TMPFS = "y";
     95         TMPFS_POSIX_ACL = "y";
     96         TMPFS_XATTR = "y";
     97 
     98         FW_LOADER = "y";
     99         FW_LOADER_COMPRESS = "y";
    100         # We don't have a user helper, so we get multiple 60s pauses
    101         # at boot time unless we disable trying to call it.
    102         # https://lkml.org/lkml/2013/8/5/175
    103         FW_LOADER_USER_HELPER = "n";
    104       };
    105     };
    106   };
    107 }