From bfa14be8634c92ca046acf0a3df2b6d5e9c3e8a5 Mon Sep 17 00:00:00 2001 From: chn Date: Sat, 22 Jul 2023 00:45:24 +0800 Subject: [PATCH] always allow overcommit memory --- modules/hardware/chn-PC.nix | 2 +- modules/hardware/default.nix | 13 ++++++++++++- modules/kernel/default.nix | 7 ------- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/modules/hardware/chn-PC.nix b/modules/hardware/chn-PC.nix index 97927617..e2ff9700 100644 --- a/modules/hardware/chn-PC.nix +++ b/modules/hardware/chn-PC.nix @@ -76,7 +76,7 @@ "net.core.somaxconn" = 8388608; "vm.oom_kill_allocating_task" = true; "vm.oom_dump_tasks" = false; - "vm.overcommit_kbytes" = 22020096; + "vm.overcommit_memory" = 1; "dev.i915.perf_stream_paranoid" = false; }; }; diff --git a/modules/hardware/default.nix b/modules/hardware/default.nix index 99736329..33e10de9 100644 --- a/modules/hardware/default.nix +++ b/modules/hardware/default.nix @@ -6,11 +6,15 @@ inputs: joystick.enable = mkOption { type = types.bool; default = false; }; 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 = []; }; }; config = let inherit (inputs.lib) mkMerge mkIf; in mkMerge [ + # bluetooth (mkIf inputs.config.nixos.hardware.bluetooth.enable { hardware.bluetooth.enable = true; }) + # joystick (mkIf inputs.config.nixos.hardware.joystick.enable { hardware = { xone.enable = true; xpadneo.enable = true; }; }) + # printer ( mkIf inputs.config.nixos.hardware.printer.enable { @@ -21,6 +25,7 @@ inputs: }; } ) + # sound ( mkIf inputs.config.nixos.hardware.sound.enable { @@ -36,10 +41,16 @@ inputs: ".*\n([[:space:]]*)(--\\[\"session\\.suspend-timeout-seconds\"][^\n]*)[\n].*" content; spaces = builtins.elemAt matched 0; comment = builtins.elemAt matched 1; - config = "[\"session.suspend-timeout-seconds\"] = 0"; + config = ''["session.suspend-timeout-seconds"] = 0''; in builtins.replaceStrings [(spaces + comment)] [(spaces + config)] content; } ) + # cpu + { + hardware.cpu = builtins.listToAttrs (builtins.map + (name: { inherit name; value = { updateMicrocode = true; }; }) + inputs.config.nixos.kernel.cpu); + } ]; } diff --git a/modules/kernel/default.nix b/modules/kernel/default.nix index 84a11149..0a824b83 100644 --- a/modules/kernel/default.nix +++ b/modules/kernel/default.nix @@ -2,7 +2,6 @@ inputs: { options.nixos.kernel = let inherit (inputs.lib) mkOption types; in { - cpu = mkOption { type = types.listOf (types.enum [ "intel" "amd" ]); default = []; }; patches = mkOption { type = types.listOf (types.enum [ "hdmi" "cjktty" ]); default = []; }; }; config = let inherit (inputs.lib) mkMerge mkIf; inherit (inputs.localLib) mkConditional; in mkMerge @@ -27,12 +26,6 @@ inputs: }); }; } - # cpu - { - hardware.cpu = builtins.listToAttrs (builtins.map - (name: { inherit name; value = { updateMicrocode = true; }; }) - inputs.config.nixos.kernel.cpu); - } # patches { boot.kernelPatches =