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