diff --git a/boot.nix b/boot.nix index 3de1d8f..9bc02ec 100644 --- a/boot.nix +++ b/boot.nix @@ -198,7 +198,7 @@ in { ++ optional cfg.rtGroupSched.enable customKernelPatches.enableRTGroupSched ++ optional cfg.energyModel.enable customKernelPatches.enableEnergyModel ++ optional cfg.amdClusterId.enable customKernelPatches.amdClusterId - ++ optional (isXanmod cfg.kernel && config.aviallon.optimizations.enable) (customKernelPatches.optimizeForCPUArch config.aviallon.general.cpuArch) + ++ optional (isXanmod cfg.kernel && config.aviallon.optimizations.enable) (customKernelPatches.optimizeForCPUArch config.aviallon.general.cpu.arch) ; diff --git a/filesystems/btrfs.nix b/filesystems/btrfs.nix index 52e2854..8455d5b 100644 --- a/filesystems/btrfs.nix +++ b/filesystems/btrfs.nix @@ -27,12 +27,12 @@ in { }; cpuThreads = mkOption { type = with types; ints.positive; - default = generalCfg.cores or 4; + default = generalCfg.cpu.threads or 4; description = "How many threads to use for hashing."; }; ioThreads = mkOption { type = with types; ints.positive; - default = myLib.math.log2 generalCfg.cores or 4; + default = myLib.math.log2 generalCfg.cpu.threads or 4; description = "How many threads to use for IO operations"; }; interval = mkOption { diff --git a/hardware/amd/cpu.nix b/hardware/amd/cpu.nix index 507ddea..8c858a8 100644 --- a/hardware/amd/cpu.nix +++ b/hardware/amd/cpu.nix @@ -2,19 +2,19 @@ with lib; let generalCfg = config.aviallon.general; - cpuIsZen = ! isNull (builtins.match "znver[0-9]" generalCfg.cpuArch); + cpuIsZen = ! isNull (builtins.match "znver[0-9]" generalCfg.cpu.arch); in { - config = mkIf (generalCfg.cpuVendor == "amd") { + config = mkIf (generalCfg.cpu.vendor == "amd") { boot.kernel.sysctl = { # Why: https://www.phoronix.com/news/Ryzen-Segv-Response # Workaround: https://forums.gentoo.org/viewtopic-p-2605135.html#2605135 - "kernel.randomize_va_space" = mkIf (generalCfg.cpuArch == "znver1" ) (warn "Disable Adress Space Layout Randomization on Ryzen 1 CPU" 0); + "kernel.randomize_va_space" = mkIf (generalCfg.cpu.arch == "znver1" ) (warn "Disable Adress Space Layout Randomization on Ryzen 1 CPU" 0); }; aviallon.boot.cmdline = { "amd_pstate" = "passive"; - } // optionalAttrs (generalCfg.cpuArch == "znver2") { + } // optionalAttrs (generalCfg.cpu.arch == "znver2") { # Required for Zen 2 "amd_pstate.shared_memory" = 1; }; diff --git a/hardware/intel/cpu.nix b/hardware/intel/cpu.nix index 2986b4e..03d2db4 100644 --- a/hardware/intel/cpu.nix +++ b/hardware/intel/cpu.nix @@ -4,7 +4,7 @@ let generalCfg = config.aviallon.general; throttledService = "lenovo_fix"; in { - config = mkIf (generalCfg.cpuVendor == "intel") { + config = mkIf (generalCfg.cpu.vendor == "intel") { aviallon.boot.cmdline = { "intel_pstate" = "passive"; }; diff --git a/nix/nix.nix b/nix/nix.nix index 63700f3..e8198de 100644 --- a/nix/nix.nix +++ b/nix/nix.nix @@ -52,7 +52,7 @@ in IOAccounting = true; IOWeight = 1024 / 10; CPUWeight = 1; - CPUQuota = (toString (generalCfg.cores * 80)) + "%"; + CPUQuota = (toString (generalCfg.cpu.threads * 80)) + "%"; Type = mkOverride 20 "simple"; }; }; @@ -103,8 +103,8 @@ in ++ optional cfg.contentAddressed "cache.ngi0.nixos.org-1:KqH5CBLNSyX184S9BKZJo1LxrxJ9ltnY2uAs5c/f1MA=" ); - nix.settings.cores = mkIf (generalCfg.cores != null) generalCfg.cores; - nix.settings.max-jobs = mkIf (generalCfg.cores != null) (math.log2 generalCfg.cores); + nix.settings.cores = mkIf (generalCfg.cpu.threads != null) generalCfg.cpu.threads; + nix.settings.max-jobs = mkIf (generalCfg.cpu.threads != null) (math.log2 generalCfg.cpu.threads); nix.registry = { nixpkgs.flake = nixpkgs; diff --git a/optimizations/optimizations.nix b/optimizations/optimizations.nix index 6b6db85..3eb2a00 100644 --- a/optimizations/optimizations.nix +++ b/optimizations/optimizations.nix @@ -100,8 +100,8 @@ in { optimizedAttrs = {} // { configureFlags = [ - "--with-cpu-64=${generalCfg.cpuArch}" "--with-arch-64=${generalCfg.cpuArch}" - "--with-tune-64=${generalCfg.cpuTune}" + "--with-cpu-64=${generalCfg.cpu.arch}" "--with-arch-64=${generalCfg.cpu.arch}" + "--with-tune-64=${generalCfg.cpu.tune}" "--with-build-config=bootstrap-lto-lean" ]; } @@ -123,7 +123,7 @@ in { recursive = 99; } super.nano; optipngOptimized = optimizePkg { - parallelize = generalCfg.cores; + parallelize = generalCfg.cpu.threads; } super.optipng; myFFmpeg = optimizePkg { lto = false; diff --git a/power.nix b/power.nix index 4597f99..906d24c 100644 --- a/power.nix +++ b/power.nix @@ -130,7 +130,7 @@ in { }; wantedBy = [ "multi-user.target" ]; description = "Undervolt Intel CPUs with supported firmware."; - enable = cfg.undervolt.cpu.enable && (generalCfg.cpuVendor == "intel"); + enable = cfg.undervolt.cpu.enable && (generalCfg.cpu.vendor == "intel"); }; systemd.services.intel-powerlimit-ac = { @@ -148,7 +148,7 @@ in { wantedBy = [ "ac-power.target" ]; description = "Set power limit of Intel CPUs with supported firmware. AC mode."; partOf = [ "ac-power.target" ]; - enable = (cfg.powerLimit.enable || cfg.temperature.enable) && (generalCfg.cpuVendor == "intel"); + enable = (cfg.powerLimit.enable || cfg.temperature.enable) && (generalCfg.cpu.vendor == "intel"); }; systemd.services.intel-powerlimit-battery = { @@ -166,7 +166,7 @@ in { wantedBy = [ "battery-power.target" ]; description = "Set power limit of Intel CPUs with supported firmware. Battery mode."; partOf = [ "battery-power.target" ]; - enable = (cfg.powerLimit.enable || cfg.temperature.enable) && (generalCfg.cpuVendor == "intel"); + enable = (cfg.powerLimit.enable || cfg.temperature.enable) && (generalCfg.cpu.vendor == "intel"); }; };