2020-04-24 23:36:52 +00:00
|
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
|
|
inherit (config.boot) kernelPatches;
|
|
|
|
|
inherit (config.boot.kernel) features randstructSeed;
|
|
|
|
|
inherit (config.boot.kernelPackages) kernel;
|
|
|
|
|
|
|
|
|
|
kernelModulesConf = pkgs.writeText "nixos.conf"
|
|
|
|
|
''
|
|
|
|
|
${concatStringsSep "\n" config.boot.kernelModules}
|
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
|
|
options = {
|
2023-02-09 11:40:11 +00:00
|
|
|
|
boot.kernel.enable = mkEnableOption (lib.mdDoc "the Linux kernel. This is useful for systemd-like containers which do not require a kernel") // {
|
2022-11-21 17:40:18 +00:00
|
|
|
|
default = true;
|
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
|
|
boot.kernel.features = mkOption {
|
|
|
|
|
default = {};
|
2021-10-06 13:57:05 +00:00
|
|
|
|
example = literalExpression "{ debug = true; }";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
internal = true;
|
2022-09-09 14:08:57 +00:00
|
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
|
This option allows to enable or disable certain kernel features.
|
|
|
|
|
It's not API, because it's about kernel feature sets, that
|
|
|
|
|
make sense for specific use cases. Mostly along with programs,
|
|
|
|
|
which would have separate nixos options.
|
|
|
|
|
`grep features pkgs/os-specific/linux/kernel/common-config.nix`
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
boot.kernelPackages = mkOption {
|
|
|
|
|
default = pkgs.linuxPackages;
|
2022-03-30 09:31:56 +00:00
|
|
|
|
type = types.raw;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
apply = kernelPackages: kernelPackages.extend (self: super: {
|
2021-07-03 03:11:41 +00:00
|
|
|
|
kernel = super.kernel.override (originalArgs: {
|
2020-04-24 23:36:52 +00:00
|
|
|
|
inherit randstructSeed;
|
2021-07-03 03:11:41 +00:00
|
|
|
|
kernelPatches = (originalArgs.kernelPatches or []) ++ kernelPatches;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
features = lib.recursiveUpdate super.kernel.features features;
|
2021-07-03 03:11:41 +00:00
|
|
|
|
});
|
2020-04-24 23:36:52 +00:00
|
|
|
|
});
|
|
|
|
|
# We don't want to evaluate all of linuxPackages for the manual
|
|
|
|
|
# - some of it might not even evaluate correctly.
|
2021-10-06 13:57:05 +00:00
|
|
|
|
defaultText = literalExpression "pkgs.linuxPackages";
|
|
|
|
|
example = literalExpression "pkgs.linuxKernel.packages.linux_5_10";
|
2022-09-09 14:08:57 +00:00
|
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
|
This option allows you to override the Linux kernel used by
|
|
|
|
|
NixOS. Since things like external kernel module packages are
|
|
|
|
|
tied to the kernel you're using, it also overrides those.
|
|
|
|
|
This option is a function that takes Nixpkgs as an argument
|
|
|
|
|
(as a convenience), and returns an attribute set containing at
|
2022-09-09 14:08:57 +00:00
|
|
|
|
the very least an attribute {var}`kernel`.
|
2020-04-24 23:36:52 +00:00
|
|
|
|
Additional attributes may be needed depending on your
|
|
|
|
|
configuration. For instance, if you use the NVIDIA X driver,
|
|
|
|
|
then it also needs to contain an attribute
|
2022-09-09 14:08:57 +00:00
|
|
|
|
{var}`nvidia_x11`.
|
2022-12-17 10:02:37 +00:00
|
|
|
|
|
|
|
|
|
Please note that we strictly support kernel versions that are
|
|
|
|
|
maintained by the Linux developers only. More information on the
|
|
|
|
|
availability of kernel versions is documented
|
|
|
|
|
[in the Linux section of the manual](https://nixos.org/manual/nixos/unstable/index.html#sec-kernel-config).
|
2020-04-24 23:36:52 +00:00
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
boot.kernelPatches = mkOption {
|
|
|
|
|
type = types.listOf types.attrs;
|
|
|
|
|
default = [];
|
2023-01-11 07:51:40 +00:00
|
|
|
|
example = literalExpression ''
|
|
|
|
|
[
|
|
|
|
|
{
|
|
|
|
|
name = "foo";
|
|
|
|
|
patch = ./foo.patch;
|
|
|
|
|
extraStructuredConfig.FOO = lib.kernel.yes;
|
|
|
|
|
features.foo = true;
|
|
|
|
|
}
|
2024-02-29 20:09:43 +00:00
|
|
|
|
{
|
|
|
|
|
name = "foo-ml-mbox";
|
|
|
|
|
patch = (fetchurl {
|
|
|
|
|
url = "https://lore.kernel.org/lkml/19700205182810.58382-1-email@domain/t.mbox.gz";
|
|
|
|
|
hash = "sha256-...";
|
|
|
|
|
});
|
|
|
|
|
}
|
2023-01-11 07:51:40 +00:00
|
|
|
|
]
|
|
|
|
|
'';
|
|
|
|
|
description = lib.mdDoc ''
|
|
|
|
|
A list of additional patches to apply to the kernel.
|
|
|
|
|
|
|
|
|
|
Every item should be an attribute set with the following attributes:
|
|
|
|
|
|
|
|
|
|
```nix
|
|
|
|
|
{
|
|
|
|
|
name = "foo"; # descriptive name, required
|
|
|
|
|
|
|
|
|
|
patch = ./foo.patch; # path or derivation that contains the patch source
|
|
|
|
|
# (required, but can be null if only config changes
|
|
|
|
|
# are needed)
|
|
|
|
|
|
2023-11-16 04:20:00 +00:00
|
|
|
|
extraStructuredConfig = { # attrset of extra configuration parameters without the CONFIG_ prefix
|
|
|
|
|
FOO = lib.kernel.yes; # (optional)
|
2023-01-11 07:51:40 +00:00
|
|
|
|
}; # values should generally be lib.kernel.yes,
|
|
|
|
|
# lib.kernel.no or lib.kernel.module
|
|
|
|
|
|
|
|
|
|
features = { # attrset of extra "features" the kernel is considered to have
|
|
|
|
|
foo = true; # (may be checked by other NixOS modules, optional)
|
|
|
|
|
};
|
|
|
|
|
|
2023-11-16 04:20:00 +00:00
|
|
|
|
extraConfig = "FOO y"; # extra configuration options in string form without the CONFIG_ prefix
|
|
|
|
|
# (optional, multiple lines allowed to specify multiple options)
|
|
|
|
|
# (deprecated, use extraStructuredConfig instead)
|
2023-01-11 07:51:40 +00:00
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
There's a small set of existing kernel patches in Nixpkgs, available as `pkgs.kernelPatches`,
|
|
|
|
|
that follow this format and can be used directly.
|
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
boot.kernel.randstructSeed = mkOption {
|
|
|
|
|
type = types.str;
|
|
|
|
|
default = "";
|
|
|
|
|
example = "my secret seed";
|
2022-09-09 14:08:57 +00:00
|
|
|
|
description = lib.mdDoc ''
|
|
|
|
|
Provides a custom seed for the {var}`RANDSTRUCT` security
|
|
|
|
|
option of the Linux kernel. Note that {var}`RANDSTRUCT` is
|
2020-04-24 23:36:52 +00:00
|
|
|
|
only enabled in NixOS hardened kernels. Using a custom seed requires
|
|
|
|
|
building the kernel and dependent packages locally, since this
|
|
|
|
|
customization happens at build time.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
boot.kernelParams = mkOption {
|
2021-10-17 02:12:59 +00:00
|
|
|
|
type = types.listOf (types.strMatching ''([^"[:space:]]|"[^"]*")+'' // {
|
|
|
|
|
name = "kernelParam";
|
|
|
|
|
description = "string, with spaces inside double quotes";
|
|
|
|
|
});
|
2020-04-24 23:36:52 +00:00
|
|
|
|
default = [ ];
|
2022-08-12 12:06:08 +00:00
|
|
|
|
description = lib.mdDoc "Parameters added to the kernel command line.";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
boot.consoleLogLevel = mkOption {
|
|
|
|
|
type = types.int;
|
|
|
|
|
default = 4;
|
2022-08-12 12:06:08 +00:00
|
|
|
|
description = lib.mdDoc ''
|
|
|
|
|
The kernel console `loglevel`. All Kernel Messages with a log level smaller
|
2020-04-24 23:36:52 +00:00
|
|
|
|
than this setting will be printed to the console.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
boot.vesa = mkOption {
|
|
|
|
|
type = types.bool;
|
|
|
|
|
default = false;
|
2022-08-12 12:06:08 +00:00
|
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
|
(Deprecated) This option, if set, activates the VESA 800x600 video
|
|
|
|
|
mode on boot and disables kernel modesetting. It is equivalent to
|
2022-08-12 12:06:08 +00:00
|
|
|
|
specifying `[ "vga=0x317" "nomodeset" ]` in the
|
|
|
|
|
{option}`boot.kernelParams` option. This option is
|
2020-04-24 23:36:52 +00:00
|
|
|
|
deprecated as of 2020: Xorg now works better with modesetting, and
|
|
|
|
|
you might want a different VESA vga setting, anyway.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
boot.extraModulePackages = mkOption {
|
|
|
|
|
type = types.listOf types.package;
|
|
|
|
|
default = [];
|
2021-10-06 13:57:05 +00:00
|
|
|
|
example = literalExpression "[ config.boot.kernelPackages.nvidia_x11 ]";
|
2022-08-12 12:06:08 +00:00
|
|
|
|
description = lib.mdDoc "A list of additional packages supplying kernel modules.";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
boot.kernelModules = mkOption {
|
|
|
|
|
type = types.listOf types.str;
|
|
|
|
|
default = [];
|
2022-08-12 12:06:08 +00:00
|
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
|
The set of kernel modules to be loaded in the second stage of
|
|
|
|
|
the boot process. Note that modules that are needed to
|
|
|
|
|
mount the root file system should be added to
|
2022-08-12 12:06:08 +00:00
|
|
|
|
{option}`boot.initrd.availableKernelModules` or
|
|
|
|
|
{option}`boot.initrd.kernelModules`.
|
2020-04-24 23:36:52 +00:00
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
boot.initrd.availableKernelModules = mkOption {
|
|
|
|
|
type = types.listOf types.str;
|
|
|
|
|
default = [];
|
|
|
|
|
example = [ "sata_nv" "ext3" ];
|
2022-08-12 12:06:08 +00:00
|
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
|
The set of kernel modules in the initial ramdisk used during the
|
|
|
|
|
boot process. This set must include all modules necessary for
|
|
|
|
|
mounting the root device. That is, it should include modules
|
|
|
|
|
for the physical device (e.g., SCSI drivers) and for the file
|
|
|
|
|
system (e.g., ext3). The set specified here is automatically
|
|
|
|
|
closed under the module dependency relation, i.e., all
|
|
|
|
|
dependencies of the modules list here are included
|
|
|
|
|
automatically. The modules listed here are available in the
|
|
|
|
|
initrd, but are only loaded on demand (e.g., the ext3 module is
|
|
|
|
|
loaded automatically when an ext3 filesystem is mounted, and
|
|
|
|
|
modules for PCI devices are loaded when they match the PCI ID
|
|
|
|
|
of a device in your system). To force a module to be loaded,
|
2022-08-12 12:06:08 +00:00
|
|
|
|
include it in {option}`boot.initrd.kernelModules`.
|
2020-04-24 23:36:52 +00:00
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
boot.initrd.kernelModules = mkOption {
|
|
|
|
|
type = types.listOf types.str;
|
|
|
|
|
default = [];
|
2022-08-12 12:06:08 +00:00
|
|
|
|
description = lib.mdDoc "List of modules that are always loaded by the initrd.";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
};
|
|
|
|
|
|
2021-02-13 14:23:35 +00:00
|
|
|
|
boot.initrd.includeDefaultModules = mkOption {
|
|
|
|
|
type = types.bool;
|
|
|
|
|
default = true;
|
2022-08-12 12:06:08 +00:00
|
|
|
|
description = lib.mdDoc ''
|
2021-02-13 14:23:35 +00:00
|
|
|
|
This option, if set, adds a collection of default kernel modules
|
2022-08-12 12:06:08 +00:00
|
|
|
|
to {option}`boot.initrd.availableKernelModules` and
|
|
|
|
|
{option}`boot.initrd.kernelModules`.
|
2021-02-13 14:23:35 +00:00
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
|
system.modulesTree = mkOption {
|
|
|
|
|
type = types.listOf types.path;
|
|
|
|
|
internal = true;
|
|
|
|
|
default = [];
|
2022-09-09 14:08:57 +00:00
|
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
|
Tree of kernel modules. This includes the kernel, plus modules
|
|
|
|
|
built outside of the kernel. Combine these into a single tree of
|
|
|
|
|
symlinks because modprobe only supports one directory.
|
|
|
|
|
'';
|
|
|
|
|
# Convert the list of path to only one path.
|
|
|
|
|
apply = pkgs.aggregateModules;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
system.requiredKernelConfig = mkOption {
|
|
|
|
|
default = [];
|
2021-10-06 13:57:05 +00:00
|
|
|
|
example = literalExpression ''
|
2020-04-24 23:36:52 +00:00
|
|
|
|
with config.lib.kernelConfig; [
|
|
|
|
|
(isYes "MODULES")
|
|
|
|
|
(isEnabled "FB_CON_DECOR")
|
|
|
|
|
(isEnabled "BLK_DEV_INITRD")
|
|
|
|
|
]
|
|
|
|
|
'';
|
|
|
|
|
internal = true;
|
|
|
|
|
type = types.listOf types.attrs;
|
2022-09-09 14:08:57 +00:00
|
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
|
This option allows modules to specify the kernel config options that
|
|
|
|
|
must be set (or unset) for the module to work. Please use the
|
|
|
|
|
lib.kernelConfig functions to build list elements.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
|
|
config = mkMerge
|
|
|
|
|
[ (mkIf config.boot.initrd.enable {
|
|
|
|
|
boot.initrd.availableKernelModules =
|
2021-02-13 14:23:35 +00:00
|
|
|
|
optionals config.boot.initrd.includeDefaultModules ([
|
|
|
|
|
# Note: most of these (especially the SATA/PATA modules)
|
2020-04-24 23:36:52 +00:00
|
|
|
|
# shouldn't be included by default since nixos-generate-config
|
|
|
|
|
# detects them, but I'm keeping them for now for backwards
|
|
|
|
|
# compatibility.
|
|
|
|
|
|
|
|
|
|
# Some SATA/PATA stuff.
|
|
|
|
|
"ahci"
|
|
|
|
|
"sata_nv"
|
|
|
|
|
"sata_via"
|
|
|
|
|
"sata_sis"
|
|
|
|
|
"sata_uli"
|
|
|
|
|
"ata_piix"
|
|
|
|
|
"pata_marvell"
|
|
|
|
|
|
2023-11-16 04:20:00 +00:00
|
|
|
|
# NVMe
|
|
|
|
|
"nvme"
|
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
|
# Standard SCSI stuff.
|
|
|
|
|
"sd_mod"
|
|
|
|
|
"sr_mod"
|
|
|
|
|
|
|
|
|
|
# SD cards and internal eMMC drives.
|
|
|
|
|
"mmc_block"
|
|
|
|
|
|
|
|
|
|
# Support USB keyboards, in case the boot fails and we only have
|
|
|
|
|
# a USB keyboard, or for LUKS passphrase prompt.
|
|
|
|
|
"uhci_hcd"
|
|
|
|
|
"ehci_hcd"
|
|
|
|
|
"ehci_pci"
|
|
|
|
|
"ohci_hcd"
|
|
|
|
|
"ohci_pci"
|
|
|
|
|
"xhci_hcd"
|
|
|
|
|
"xhci_pci"
|
|
|
|
|
"usbhid"
|
|
|
|
|
"hid_generic" "hid_lenovo" "hid_apple" "hid_roccat"
|
2022-04-03 18:54:34 +00:00
|
|
|
|
"hid_logitech_hidpp" "hid_logitech_dj" "hid_microsoft" "hid_cherry"
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
|
] ++ optionals pkgs.stdenv.hostPlatform.isx86 [
|
2020-04-24 23:36:52 +00:00
|
|
|
|
# Misc. x86 keyboard stuff.
|
|
|
|
|
"pcips2" "atkbd" "i8042"
|
|
|
|
|
|
|
|
|
|
# x86 RTC needed by the stage 2 init script.
|
|
|
|
|
"rtc_cmos"
|
2021-02-13 14:23:35 +00:00
|
|
|
|
]);
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
|
|
boot.initrd.kernelModules =
|
2021-02-13 14:23:35 +00:00
|
|
|
|
optionals config.boot.initrd.includeDefaultModules [
|
|
|
|
|
# For LVM.
|
2020-04-24 23:36:52 +00:00
|
|
|
|
"dm_mod"
|
|
|
|
|
];
|
|
|
|
|
})
|
|
|
|
|
|
2022-11-21 17:40:18 +00:00
|
|
|
|
(mkIf config.boot.kernel.enable {
|
2020-04-24 23:36:52 +00:00
|
|
|
|
system.build = { inherit kernel; };
|
|
|
|
|
|
|
|
|
|
system.modulesTree = [ kernel ] ++ config.boot.extraModulePackages;
|
|
|
|
|
|
2023-08-10 07:59:29 +00:00
|
|
|
|
# Not required for, e.g., containers as they don't have their own kernel or initrd.
|
|
|
|
|
# They boot directly into stage 2.
|
|
|
|
|
system.systemBuilderArgs.kernelParams = config.boot.kernelParams;
|
|
|
|
|
system.systemBuilderCommands =
|
|
|
|
|
let
|
|
|
|
|
kernelPath = "${config.boot.kernelPackages.kernel}/" +
|
|
|
|
|
"${config.system.boot.loader.kernelFile}";
|
|
|
|
|
initrdPath = "${config.system.build.initialRamdisk}/" +
|
|
|
|
|
"${config.system.boot.loader.initrdFile}";
|
|
|
|
|
in
|
|
|
|
|
''
|
|
|
|
|
if [ ! -f ${kernelPath} ]; then
|
|
|
|
|
echo "The bootloader cannot find the proper kernel image."
|
|
|
|
|
echo "(Expecting ${kernelPath})"
|
|
|
|
|
false
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
ln -s ${kernelPath} $out/kernel
|
|
|
|
|
ln -s ${config.system.modulesTree} $out/kernel-modules
|
|
|
|
|
${optionalString (config.hardware.deviceTree.package != null) ''
|
|
|
|
|
ln -s ${config.hardware.deviceTree.package} $out/dtbs
|
|
|
|
|
''}
|
|
|
|
|
|
|
|
|
|
echo -n "$kernelParams" > $out/kernel-params
|
|
|
|
|
|
|
|
|
|
ln -s ${initrdPath} $out/initrd
|
|
|
|
|
|
|
|
|
|
ln -s ${config.system.build.initialRamdiskSecretAppender}/bin/append-initrd-secrets $out
|
|
|
|
|
|
|
|
|
|
ln -s ${config.hardware.firmware}/lib/firmware $out/firmware
|
|
|
|
|
'';
|
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
|
# Implement consoleLogLevel both in early boot and using sysctl
|
|
|
|
|
# (so you don't need to reboot to have changes take effect).
|
|
|
|
|
boot.kernelParams =
|
|
|
|
|
[ "loglevel=${toString config.boot.consoleLogLevel}" ] ++
|
|
|
|
|
optionals config.boot.vesa [ "vga=0x317" "nomodeset" ];
|
|
|
|
|
|
|
|
|
|
boot.kernel.sysctl."kernel.printk" = mkDefault config.boot.consoleLogLevel;
|
|
|
|
|
|
|
|
|
|
boot.kernelModules = [ "loop" "atkbd" ];
|
|
|
|
|
|
|
|
|
|
# Create /etc/modules-load.d/nixos.conf, which is read by
|
|
|
|
|
# systemd-modules-load.service to load required kernel modules.
|
|
|
|
|
environment.etc =
|
|
|
|
|
{ "modules-load.d/nixos.conf".source = kernelModulesConf;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
systemd.services.systemd-modules-load =
|
|
|
|
|
{ wantedBy = [ "multi-user.target" ];
|
|
|
|
|
restartTriggers = [ kernelModulesConf ];
|
|
|
|
|
serviceConfig =
|
|
|
|
|
{ # Ignore failed module loads. Typically some of the
|
|
|
|
|
# modules in ‘boot.kernelModules’ are "nice to have but
|
|
|
|
|
# not required" (e.g. acpi-cpufreq), so we don't want to
|
|
|
|
|
# barf on those.
|
|
|
|
|
SuccessExitStatus = "0 1";
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
lib.kernelConfig = {
|
|
|
|
|
isYes = option: {
|
|
|
|
|
assertion = config: config.isYes option;
|
|
|
|
|
message = "CONFIG_${option} is not yes!";
|
|
|
|
|
configLine = "CONFIG_${option}=y";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
isNo = option: {
|
|
|
|
|
assertion = config: config.isNo option;
|
|
|
|
|
message = "CONFIG_${option} is not no!";
|
|
|
|
|
configLine = "CONFIG_${option}=n";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
isModule = option: {
|
|
|
|
|
assertion = config: config.isModule option;
|
|
|
|
|
message = "CONFIG_${option} is not built as a module!";
|
|
|
|
|
configLine = "CONFIG_${option}=m";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
### Usually you will just want to use these two
|
|
|
|
|
# True if yes or module
|
|
|
|
|
isEnabled = option: {
|
|
|
|
|
assertion = config: config.isEnabled option;
|
|
|
|
|
message = "CONFIG_${option} is not enabled!";
|
|
|
|
|
configLine = "CONFIG_${option}=y";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
# True if no or omitted
|
|
|
|
|
isDisabled = option: {
|
|
|
|
|
assertion = config: config.isDisabled option;
|
|
|
|
|
message = "CONFIG_${option} is not disabled!";
|
|
|
|
|
configLine = "CONFIG_${option}=n";
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
# The config options that all modules can depend upon
|
|
|
|
|
system.requiredKernelConfig = with config.lib.kernelConfig;
|
|
|
|
|
[
|
|
|
|
|
# !!! Should this really be needed?
|
|
|
|
|
(isYes "MODULES")
|
|
|
|
|
(isYes "BINFMT_ELF")
|
|
|
|
|
] ++ (optional (randstructSeed != "") (isYes "GCC_PLUGIN_RANDSTRUCT"));
|
|
|
|
|
|
|
|
|
|
# nixpkgs kernels are assumed to have all required features
|
|
|
|
|
assertions = if config.boot.kernelPackages.kernel ? features then [] else
|
|
|
|
|
let cfg = config.boot.kernelPackages.kernel.config; in map (attrs:
|
|
|
|
|
{ assertion = attrs.assertion cfg; inherit (attrs) message; }
|
|
|
|
|
) config.system.requiredKernelConfig;
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
}
|