nixos-config/lib/fudo/system.nix

44 lines
1.2 KiB
Nix
Raw Normal View History

2020-06-06 18:58:13 -07:00
{ pkgs, lib, config, ... }:
with lib;
let
cfg = config.fudo.system;
in {
options.fudo.system = {
disableTransparentHugePages = mkOption {
type = types.bool;
description = ''
Disable transparent huge pages (recommended for database loads, in
particular for Redis.
'';
default = false;
};
postHugePageServices = mkOption {
type = with types; listOf str;
description = "List of systemd services that should wait until after THP are disabled.";
default = [];
example = ["redis.service"];
};
2020-07-23 22:38:48 -07:00
tmpOnTmpfs = mkOption {
type = types.bool;
description = "Put tmp filesystem on tmpfs (needs enough RAM).";
default = true;
};
2020-06-06 18:58:13 -07:00
};
config = mkIf cfg.disableTransparentHugePages {
systemd.services.disableHugePages = {
description = "Turn off Transparent Huge Pages (https://www.kernel.org/doc/Documentation/vm/transhuge.txt)";
after = [ "sysinit.target" "localfs-target" ];
before = cfg.postHugePageServices;
enable = true;
serviceConfig = {
ExecStart = "/bin/sh -c 'echo never | tee /sys/kernel/mm/transparent_hugepage/enabled > /dev/null";
Type = "oneshot";
};
};
};
}