1
1
mirror of https://github.com/NixOS/mobile-nixos.git synced 2025-01-08 12:48:50 +03:00
mobile-nixos/modules/kernel-config.nix
Samuel Dionne-Riel a5135286a8 kernel-config: Init module to define minimal required options
This is not really meant to provide a user-accessible way to configure
the kernel... But it also works that way I guess!

For now it is *meant* to provide *required options*, so that validation
(and soon normalization) always includes required options.
2021-08-30 17:25:34 -04:00

96 lines
2.5 KiB
Nix

{ config, lib, options, pkgs, ... }:
let
inherit (lib)
mkOption
types
;
in
{
options = {
mobile = {
kernel = {
structuredConfig = mkOption {
type = with types; listOf (functionTo attrs);
description = ''
Functions returning kernel structured config.
The functions take one argument, an attrset of helpers.
These helpers are expected to be used with `with`, they
provide the `yes`, `no`, `whenOlder` and similar helpers
from `lib.kernel`.
The `whenHelpers` are configured with the appropriate
version already.
'';
};
};
};
};
config = {
mobile.kernel.structuredConfig = [
# Basic universal options
(helpers: with helpers; {
# POSIX_ACL and XATTR are generally needed.
TMPFS_POSIX_ACL = yes;
TMPFS_XATTR = yes;
# Executive decision that EXT4 is required.
EXT4_FS = yes;
EXT4_FS_POSIX_ACL = yes;
# Required config for Nix
NAMESPACES = yes;
USER_NS = yes;
PID_NS = yes;
# Additional options
SYSVIPC = yes;
# Options from Android kernels that break stuff
# While not *universally available*, it's universally required to
# be turned off.
ANDROID_PARANOID_NETWORK = no;
})
# Needed for systemd
(helpers: with helpers; {
# Kernel configuration as required by systemd
# As of https://github.com/systemd/systemd/blob/4917c15af7c2dfe553b8e0dbf22b4fb7cec958de/README#L35
DEVTMPFS = yes;
CGROUPS = yes;
INOTIFY_USER = yes;
SIGNALFD = yes;
TIMERFD = yes;
EPOLL = yes;
NET = yes;
UNIX = yes;
SYSFS = yes;
PROC_FS = yes;
FHANDLE = yes;
CRYPTO_USER_API_HASH = yes;
CRYPTO_HMAC = yes;
CRYPTO_SHA256 = yes;
SYSFS_DEPRECATED = no;
UEVENT_HELPER_PATH = freeform ''""'';
FW_LOADER_USER_HELPER = option no;
BLK_DEV_BSG = yes;
DEVPTS_MULTIPLE_INSTANCES = whenOlder "4.7" yes;
})
];
nixpkgs.overlays = [(final: super: {
systemBuild-structuredConfig = version:
let
helpers = lib.kernel // (lib.kernel.whenHelpers version);
structuredConfig =
lib.mkMerge
(map (fn: fn helpers) config.mobile.kernel.structuredConfig)
;
in
structuredConfig
;
})];
};
}