1
1
mirror of https://github.com/NixOS/mobile-nixos.git synced 2024-12-15 02:43:24 +03:00
mobile-nixos/modules/initrd-kernel.nix
Samuel Dionne-Riel 92324964d1 initrd-kernel: Add options for kernel package
We cannot use a "linuxPackagesFor" attrset due to older OEM kernels.
2020-05-24 20:13:07 -04:00

93 lines
2.2 KiB
Nix

{ config, lib, options, pkgs, ... }:
let
inherit (lib)
mergeEqualOption
mkIf
mkOption
types
;
cfg = config.mobile.boot.stage-1.kernel;
device_config = config.mobile.device;
modulesClosure = pkgs.makeModulesClosure {
kernel = cfg.package;
allowMissing = true;
rootModules = cfg.modules ++ cfg.additionalModules;
firmware = cfg.firmwares;
};
in
{
# Note: These options are provided *instead* of `boot.initrd.*`, as we are
# not re-using the `initrd` options.
options.mobile.boot.stage-1.kernel = {
modular = mkOption {
type = types.bool;
default = false;
description = ''
Whether the kernel is built with modules or not.
This will enable modules closure generation and listing modules
to bundle and load.
'';
};
modules = mkOption {
type = types.listOf types.str;
default = [
];
description = ''
Module names to add to the closure.
They will be modprobed.
'';
};
additionalModules = mkOption {
type = types.listOf types.str;
default = [
];
description = ''
Module names to add to the closure.
They will not be modprobed.
'';
};
firmwares = mkOption {
type = types.listOf types.str;
default = [];
description = ''
Firmwares to add to the cloure.
'';
};
# We cannot use `linuxPackagesFor` as older kernels cause eval-time assertions...
# This is bad form, but is already in nixpkgs :(.
package = mkOption {
type = types.package;
description = ''
Kernel to be used by the system-type to boot into the Mobile NixOS
stage-1.
This is not using a kernelPackages attrset, but a kernel derivation directly.
'';
};
};
config.mobile.boot.stage-1 = (mkIf cfg.modular {
contents = [
{ object = "${modulesClosure}/lib/modules"; symlink = "/lib/modules"; }
{ object = "${modulesClosure}/lib/firmware"; symlink = "/lib/firmware"; }
];
kernel.modules = [
# Basic always-needed kernel modules.
"loop"
# Filesystems
"nls_cp437"
"nls_iso8859-1"
"fat"
"vfat"
"ext4"
"crc32c"
];
});
}