mirror of
https://github.com/CHN-beta/nixos.git
synced 2026-01-12 04:39:23 +08:00
modules.hardware.cpu: cleanup
This commit is contained in:
@@ -21,7 +21,7 @@ inputs:
|
||||
nixpkgs.march = "silvermont";
|
||||
network = {};
|
||||
};
|
||||
hardware = { cpus = [ "intel" ]; gpu.type = "intel"; };
|
||||
hardware = { cpu = "intel"; gpu.type = "intel"; };
|
||||
services =
|
||||
{
|
||||
sshd = {};
|
||||
|
||||
@@ -20,7 +20,7 @@ inputs:
|
||||
};
|
||||
nixpkgs.march = "tigerlake";
|
||||
};
|
||||
hardware = { cpus = [ "intel" ]; gpu.type = "intel"; };
|
||||
hardware = { cpu = "intel"; gpu.type = "intel"; };
|
||||
services =
|
||||
{
|
||||
xray.client = {};
|
||||
|
||||
@@ -52,12 +52,7 @@ inputs:
|
||||
nixpkgs = { march = "znver4"; cuda.capabilities = [ "8.9" ]; };
|
||||
sysctl.laptop-mode = 5;
|
||||
};
|
||||
hardware =
|
||||
{
|
||||
cpus = [ "amd" ];
|
||||
gpu = { type = "nvidia"; nvidia.dynamicBoost = true; };
|
||||
legion = {};
|
||||
};
|
||||
hardware = { cpu = "amd"; gpu = { type = "nvidia"; nvidia.dynamicBoost = true; }; legion = {}; };
|
||||
services =
|
||||
{
|
||||
samba =
|
||||
|
||||
@@ -18,7 +18,7 @@ inputs:
|
||||
swap = [ "/nix/swap/swap" ];
|
||||
};
|
||||
};
|
||||
hardware.cpus = [ "intel" ];
|
||||
hardware.cpu = "intel";
|
||||
services =
|
||||
{
|
||||
sshd.passwordAuthentication = true;
|
||||
|
||||
@@ -5,7 +5,7 @@ inputs:
|
||||
nixos =
|
||||
{
|
||||
model.cluster.nodeType = "master";
|
||||
hardware.cpus = [ "intel" ];
|
||||
hardware.cpu = "intel";
|
||||
system =
|
||||
{
|
||||
nixpkgs.march = "skylake";
|
||||
|
||||
@@ -4,7 +4,7 @@ inputs:
|
||||
{
|
||||
nixos =
|
||||
{
|
||||
hardware.cpus = [ "amd" ];
|
||||
hardware.cpu = "amd";
|
||||
system =
|
||||
{
|
||||
nixpkgs.march = "znver3";
|
||||
|
||||
@@ -30,7 +30,7 @@ inputs:
|
||||
};
|
||||
};
|
||||
};
|
||||
hardware.cpus = [ "intel" ];
|
||||
hardware.cpu = "intel";
|
||||
services =
|
||||
{
|
||||
beesd."/" = { hashTableSizeMB = 128; threads = 4;};
|
||||
|
||||
@@ -17,7 +17,7 @@ inputs:
|
||||
nixpkgs.march = "znver4";
|
||||
network = {};
|
||||
};
|
||||
hardware.cpus = [ "amd" ];
|
||||
hardware.cpu = "amd";
|
||||
services.sshd = {};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -17,7 +17,7 @@ inputs:
|
||||
nixpkgs.march = "znver4";
|
||||
network = { dhcp = [ "nixvirt" ]; bridge.nixvirt.interfaces = [ "enp1s0" ]; };
|
||||
};
|
||||
hardware.cpus = [ "amd" ];
|
||||
hardware.cpu = "amd";
|
||||
services =
|
||||
{
|
||||
sshd = {};
|
||||
|
||||
@@ -17,7 +17,7 @@ inputs:
|
||||
nixpkgs.march = "haswell";
|
||||
network = {};
|
||||
};
|
||||
hardware.cpus = [ "intel" ];
|
||||
hardware.cpu = "intel";
|
||||
services =
|
||||
{
|
||||
sshd = {};
|
||||
|
||||
16
modules/hardware/cpu.nix
Normal file
16
modules/hardware/cpu.nix
Normal file
@@ -0,0 +1,16 @@
|
||||
inputs:
|
||||
{
|
||||
options.nixos.hardware.cpu = let inherit (inputs.lib) mkOption types; in mkOption
|
||||
{ type = types.nullOr (types.enum [ "intel" "amd" ]); default = null; };
|
||||
config = let inherit (inputs.config.nixos.hardware) cpu; in inputs.lib.mkIf (cpu != null) (inputs.lib.mkMerge
|
||||
[
|
||||
(inputs.lib.mkIf (cpu == "intel")
|
||||
{
|
||||
hardware.cpu.intel.updateMicrocode = true;
|
||||
boot.initrd.availableKernelModules =
|
||||
[ "intel_cstate" "aesni_intel" "intel_cstate" "intel_uncore" "intel_uncore_frequency" "intel_powerclamp" ];
|
||||
})
|
||||
(inputs.lib.mkIf (cpu == "amd")
|
||||
{ hardware.cpu.amd.updateMicrocode = true; environment.systemPackages = [ inputs.pkgs.zenmonitor ]; })
|
||||
]);
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
inputs:
|
||||
{
|
||||
options.nixos.hardware.cpus = let inherit (inputs.lib) mkOption types; in mkOption
|
||||
{ type = types.listOf (types.enum [ "intel" "amd" ]); default = []; };
|
||||
config = let inherit (inputs.config.nixos.hardware) cpus; in inputs.lib.mkIf (cpus != []) (inputs.lib.mkMerge
|
||||
[
|
||||
(inputs.lib.mkIf (builtins.elem "intel" cpus)
|
||||
{
|
||||
hardware.cpu.intel.updateMicrocode = true;
|
||||
boot.initrd.availableKernelModules =
|
||||
[ "intel_cstate" "aesni_intel" "intel_cstate" "intel_uncore" "intel_uncore_frequency" "intel_powerclamp" ];
|
||||
})
|
||||
(inputs.lib.mkIf (builtins.elem "amd" cpus)
|
||||
{ hardware.cpu.amd.updateMicrocode = true; environment.systemPackages = [ inputs.pkgs.zenmonitor ]; })
|
||||
]);
|
||||
}
|
||||
@@ -12,14 +12,10 @@ inputs:
|
||||
config = let inherit (inputs.config.nixos.services) kvm; in inputs.lib.mkIf (kvm != null)
|
||||
{
|
||||
nix.settings.system-features = [ "kvm" ];
|
||||
boot =
|
||||
boot = let inherit (inputs.config.nixos.hardware) cpu; in
|
||||
{
|
||||
kernelModules =
|
||||
let modules = { intel = [ "kvm-intel" ]; amd = []; };
|
||||
in builtins.concatLists (builtins.map (cpu: modules.${cpu}) inputs.config.nixos.hardware.cpus);
|
||||
extraModprobeConfig =
|
||||
let configs = { intel = "options kvm_intel nested=1"; amd = ""; };
|
||||
in builtins.concatStringsSep "\n" (builtins.map (cpu: configs.${cpu}) inputs.config.nixos.hardware.cpus);
|
||||
kernelModules = { intel = [ "kvm-intel" ]; amd = []; }.${cpu};
|
||||
extraModprobeConfig = { intel = "options kvm_intel nested=1"; amd = ""; }.${cpu};
|
||||
};
|
||||
virtualisation =
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user