refactor kernel module
This commit is contained in:
@@ -6,6 +6,8 @@
|
||||
}: let
|
||||
inherit (lib) mkOption types;
|
||||
cfg = config.nixos.boot.kernel;
|
||||
|
||||
hasHardware = hw: builtins.elem hw cfg.hardware;
|
||||
in {
|
||||
options = {
|
||||
nixos.boot.kernel = {
|
||||
@@ -16,21 +18,21 @@ in {
|
||||
};
|
||||
|
||||
hardware = mkOption {
|
||||
type = types.enum ["amd" "nvidia"];
|
||||
default = "";
|
||||
description = "Hardware type (GPU) configuration.";
|
||||
type = types.listOf (types.enum ["amd" "intel" "nvidia"]);
|
||||
default = [];
|
||||
description = "List of hardware types (e.g. GPU and CPU vendors) to configure kernel settings for.";
|
||||
};
|
||||
|
||||
extraKernelParams = mkOption {
|
||||
type = types.listOf lib.types.str;
|
||||
type = types.listOf types.str;
|
||||
default = [];
|
||||
description = "Additional kernel parameters.";
|
||||
};
|
||||
|
||||
extraBlacklistedModules = mkOption {
|
||||
type = types.listOf lib.types.str;
|
||||
type = types.listOf types.str;
|
||||
default = [];
|
||||
description = "Additional kernel nixos.to blacklist.";
|
||||
description = "Additional kernel modules to blacklist.";
|
||||
};
|
||||
};
|
||||
};
|
||||
@@ -40,7 +42,7 @@ in {
|
||||
consoleLogLevel = 3;
|
||||
|
||||
kernelPackages = let
|
||||
variant = cfg.variant or "latest"; # Ensure a default value
|
||||
variant = cfg.variant or "latest";
|
||||
in
|
||||
if variant == "stable"
|
||||
then pkgs.linuxPackages
|
||||
@@ -51,28 +53,41 @@ in {
|
||||
else throw "Unknown kernel variant: ${variant}";
|
||||
|
||||
kernelParams =
|
||||
[
|
||||
"quiet"
|
||||
"splash"
|
||||
]
|
||||
["quiet" "splash"]
|
||||
++ (
|
||||
if cfg.hardware == "amd"
|
||||
if hasHardware "amd"
|
||||
then ["amd_pstate=active"]
|
||||
else []
|
||||
)
|
||||
++ (
|
||||
if hasHardware "intel"
|
||||
then []
|
||||
else []
|
||||
)
|
||||
++ (
|
||||
if hasHardware "nvidia"
|
||||
then []
|
||||
else []
|
||||
)
|
||||
++ cfg.extraKernelParams;
|
||||
|
||||
blacklistedKernelModules =
|
||||
(
|
||||
if cfg.hardware == "nvidia"
|
||||
if hasHardware "amd"
|
||||
then []
|
||||
else []
|
||||
)
|
||||
++ (
|
||||
if hasHardware "intel"
|
||||
then []
|
||||
else []
|
||||
)
|
||||
++ (
|
||||
if hasHardware "nvidia"
|
||||
then ["nouveau"]
|
||||
else []
|
||||
)
|
||||
++ cfg.extraBlacklistedModules;
|
||||
};
|
||||
|
||||
# chaotic = mkIf (cfg.variant == "cachyos") {
|
||||
# environment.systemPackages = [pkgs.scx.lavd];
|
||||
# };
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user