modules/initrd-kernel: Add toggle for upstream NixOS kernel
let
inherit (lib)
+ literalExpression
mergeEqualOption
mkDefault
mkIf
+ mkMerge
mkOption
types
;
@@ -25,6 +27,16 @@ 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 = {
+ useNixOSKernel = mkOption {
+ type = types.bool;
+ default = !config.mobile.enable;
+ defaultText = literalExpression "!config.mobile.enable";
+ description = ''
+ Whether Mobile NixOS relies on upstream NixOS settings for kernel config.
+
+ Enable this when using the NixOS machinery for kernels.
+ '';
+ };
modular = mkOption {
type = types.bool;
default = false;
@@ -73,7 +85,10 @@ in
};
};
- config.mobile.boot.stage-1 = (mkIf cfg.modular {
+ config = mkMerge [
+ # This can always be configured, as it does not affect the NixOS configuration.
+ {
+ mobile.boot.stage-1 = (mkIf cfg.modular {
firmware = [ modulesClosure ];
contents = [
{ object = "${modulesClosure}/lib/modules"; symlink = "/lib/modules"; }
@@ -92,8 +107,10 @@ in
"crc32c"
];
});
-
- config.boot.kernelPackages = mkDefault (
+ }
+ # Options affecting the NixOS configuration
+ (mkIf (!cfg.useNixOSKernel) {
+ boot.kernelPackages = mkDefault (
if (supportsStage-0 && config.mobile.rootfs.shared.enabled) || cfg.package == null
then let
self = {
@@ -111,12 +128,14 @@ in
else (pkgs.recurseIntoAttrs (pkgs.linuxPackagesFor cfg.package))
);
- config.system.boot.loader.kernelFile = mkIf (cfg.package != null && cfg.package ? file) (
+ system.boot.loader.kernelFile = mkIf (cfg.package != null && cfg.package ? file) (
mkDefault cfg.package.file
);
# Disable kernel config checks as it's EXTREMELY nixpkgs-kernel centric.
# We're duplicating that good work for the time being.
- config.system.requiredKernelConfig = lib.mkForce [];
+ system.requiredKernelConfig = lib.mkForce [];
+ })
+ ];
}
