整理内核模块

This commit is contained in:
2023-07-22 14:16:01 +08:00
parent 3bf9c52bab
commit 9faeb54ebd
3 changed files with 26 additions and 7 deletions

View File

@@ -179,6 +179,7 @@
hardware =
{
cpu = [ "intel" ];
gpu = [ "intel" "nvidia" ];
bluetooth.enable = true;
joystick.enable = true;
printer.enable = true;

View File

@@ -8,14 +8,10 @@ inputs:
# boot.extraModulePackages = [ yourmodulename ];
boot.extraModprobeConfig = "options kvm_intel nested=1";
# initrd, luks
boot.initrd =
boot.initrd.systemd.services."systemd-cryptsetup@swap" =
{
availableKernelModules =
[ "i915" "intel_cstate" "nvidia" "nvidia_drm" "nvidia_modeset" "nvidia_uvm" "aesni_intel" ];
systemd.services."systemd-cryptsetup@swap" =
{
before = [ "systemd-cryptsetup@root.service" ];
overrideStrategy = "asDropin";
before = [ "systemd-cryptsetup@root.service" ];
overrideStrategy = "asDropin";
};
# impermanence

View File

@@ -7,6 +7,7 @@ inputs:
printer.enable = mkOption { type = types.bool; default = false; };
sound.enable = mkOption { type = types.bool; default = false; };
cpu = mkOption { type = types.listOf (types.enum [ "intel" "amd" ]); default = []; };
gpu = mkOption { type = types.listOf (types.enum [ "intel" "nvidia" ]); default = []; };
};
config = let inherit (inputs.lib) mkMerge mkIf; in mkMerge
[
@@ -51,6 +52,27 @@ inputs:
hardware.cpu = builtins.listToAttrs (builtins.map
(name: { inherit name; value = { updateMicrocode = true; }; })
inputs.config.nixos.hardware.cpu);
boot.initrd.availableKernelModules =
let
modules =
{
intel = [ "intel_cstate" "aesni_intel" ];
amd = [];
};
in
builtins.concatLists (builtins.map (cpu: modules.${cpu}) inputs.config.nixos.hardware.cpu);
}
# gpu
{
boot.initrd.availableKernelModules =
let
modules =
{
intel = [ "i915" ];
nvidia = [ "nvidia" "nvidia_drm" "nvidia_modeset" "nvidia_uvm" ];
};
in
builtins.concatLists (builtins.map (cpu: modules.${cpu}) inputs.config.nixos.hardware.cpu);
}
];
}