2020-05-24 23:15:47 +03:00
|
|
|
{ config, lib, options, pkgs, ... }:
|
2018-06-24 00:45:51 +03:00
|
|
|
|
|
|
|
let
|
2020-05-24 23:15:47 +03:00
|
|
|
|
|
|
|
inherit (lib)
|
|
|
|
mergeEqualOption
|
|
|
|
mkIf
|
|
|
|
mkOption
|
|
|
|
types
|
|
|
|
;
|
2018-06-24 00:45:51 +03:00
|
|
|
cfg = config.mobile.boot.stage-1.kernel;
|
|
|
|
device_config = config.mobile.device;
|
|
|
|
|
|
|
|
modulesClosure = pkgs.makeModulesClosure {
|
2020-05-24 23:15:47 +03:00
|
|
|
kernel = cfg.package;
|
2018-06-24 00:45:51 +03:00
|
|
|
allowMissing = true;
|
2020-05-24 22:41:27 +03:00
|
|
|
rootModules = cfg.modules ++ cfg.additionalModules;
|
2018-06-24 00:45:51 +03:00
|
|
|
firmware = cfg.firmwares;
|
|
|
|
};
|
|
|
|
in
|
|
|
|
{
|
2020-05-24 22:41:27 +03:00
|
|
|
# Note: These options are provided *instead* of `boot.initrd.*`, as we are
|
|
|
|
# not re-using the `initrd` options.
|
2018-06-24 00:45:51 +03:00
|
|
|
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 {
|
2019-09-13 05:23:13 +03:00
|
|
|
type = types.listOf types.str;
|
2018-06-24 00:45:51 +03:00
|
|
|
default = [
|
|
|
|
];
|
|
|
|
description = ''
|
|
|
|
Module names to add to the closure.
|
|
|
|
They will be modprobed.
|
|
|
|
'';
|
|
|
|
};
|
2020-05-24 22:41:27 +03:00
|
|
|
additionalModules = mkOption {
|
2019-09-13 05:23:13 +03:00
|
|
|
type = types.listOf types.str;
|
2018-06-24 00:45:51 +03:00
|
|
|
default = [
|
|
|
|
];
|
|
|
|
description = ''
|
|
|
|
Module names to add to the closure.
|
|
|
|
They will not be modprobed.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
firmwares = mkOption {
|
2019-09-13 05:23:13 +03:00
|
|
|
type = types.listOf types.str;
|
2018-06-24 00:45:51 +03:00
|
|
|
default = [];
|
|
|
|
description = ''
|
2020-10-14 00:23:24 +03:00
|
|
|
Firmwares to add to the closure.
|
2018-06-24 00:45:51 +03:00
|
|
|
'';
|
|
|
|
};
|
2020-05-24 23:15:47 +03:00
|
|
|
# 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.
|
|
|
|
'';
|
|
|
|
};
|
2018-06-24 00:45:51 +03:00
|
|
|
};
|
|
|
|
|
2020-05-24 23:15:47 +03:00
|
|
|
config.mobile.boot.stage-1 = (mkIf cfg.modular {
|
2020-07-06 07:18:47 +03:00
|
|
|
firmware = [ modulesClosure ];
|
2019-12-23 22:05:17 +03:00
|
|
|
contents = [
|
|
|
|
{ object = "${modulesClosure}/lib/modules"; symlink = "/lib/modules"; }
|
|
|
|
];
|
2018-06-24 00:45:51 +03:00
|
|
|
kernel.modules = [
|
|
|
|
# Basic always-needed kernel modules.
|
|
|
|
"loop"
|
|
|
|
|
|
|
|
# Filesystems
|
|
|
|
"nls_cp437"
|
|
|
|
"nls_iso8859-1"
|
|
|
|
"fat"
|
|
|
|
"vfat"
|
|
|
|
|
|
|
|
"ext4"
|
|
|
|
"crc32c"
|
|
|
|
];
|
2020-05-24 23:15:47 +03:00
|
|
|
});
|
2018-06-24 00:45:51 +03:00
|
|
|
}
|
|
|
|
|