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;
|
|
|
|
"vm.overcommit_memory" = 1;
|
|
|
|
"kernel.sysrq" = 438;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
(inputs.lib.mkIf (sysctl.laptop-mode != null) { boot.kernel.sysctl."vm.laptop_mode" = sysctl.laptop-mode; })
|
|
|
|
];
|
2023-12-19 18:54:31 +08:00
|
|
|
}
|