nixos/modules/system/sysctl.nix

23 lines
738 B
Nix
Raw Permalink Normal View History

2023-12-19 18:54:31 +08:00
inputs:
{
options.nixos.system.sysctl = let inherit (inputs.lib) mkOption types; in
{
laptop-mode = mkOption { type = types.nullOr types.int; default = null; };
};
2024-03-27 18:47:56 +08:00
config = let inherit (inputs.config.nixos.system) sysctl; in inputs.lib.mkMerge
[
{
boot.kernel.sysctl =
2023-12-19 18:54:31 +08:00
{
2024-03-27 18:47:56 +08:00
"vm.oom_kill_allocating_task" = true;
"vm.oom_dump_tasks" = false;
2024-05-22 10:44:41 +08:00
"vm.overcommit_memory" = inputs.lib.mkDefault 1;
2024-03-27 18:47:56 +08:00
"kernel.sysrq" = 438;
# set to larger value, otherwise the system will be very slow on low memory machines
"vm.vfs_cache_pressure" = 100;
2024-03-27 18:47:56 +08:00
};
}
(inputs.lib.mkIf (sysctl.laptop-mode != null) { boot.kernel.sysctl."vm.laptop_mode" = sysctl.laptop-mode; })
];
2023-12-19 18:54:31 +08:00
}