···
cfg = config.services.earlyoom;
7
-
mkDefault mkEnableOption mkIf mkOption types
8
-
mkRemovedOptionModule literalExpression
9
-
escapeShellArg concatStringsSep optional optionalString;
15
+
mkRemovedOptionModule
22
+
maintainers = with lib.maintainers; [ AndersonTorres ];
options.services.earlyoom = {
enable = mkEnableOption "early out of memory killing";
28
+
package = mkPackageOption pkgs "earlyoom" { };
freeMemThreshold = mkOption {
type = types.ints.between 1 100;
···
systemd.services.earlyoom = {
description = "Early OOM Daemon for Linux";
wantedBy = [ "multi-user.target" ];
141
-
path = optional cfg.enableNotifications pkgs.dbus;
155
+
path = optionals cfg.enableNotifications [ pkgs.dbus ];
StandardError = "journal";
ExecStart = concatStringsSep " " ([
145
-
"${pkgs.earlyoom}/bin/earlyoom"
159
+
"${lib.getExe cfg.package}"
("-m ${toString cfg.freeMemThreshold}"
147
-
+ optionalString (cfg.freeMemKillThreshold != null) ",${toString cfg.freeMemKillThreshold}")
161
+
+ optionalString (cfg.freeMemKillThreshold != null) ",${toString cfg.freeMemKillThreshold}")
("-s ${toString cfg.freeSwapThreshold}"
149
-
+ optionalString (cfg.freeSwapKillThreshold != null) ",${toString cfg.freeSwapKillThreshold}")
163
+
+ optionalString (cfg.freeSwapKillThreshold != null) ",${toString cfg.freeSwapKillThreshold}")
"-r ${toString cfg.reportInterval}"
152
-
++ optional cfg.enableDebugInfo "-d"
153
-
++ optional cfg.enableNotifications "-n"
154
-
++ optional (cfg.killHook != null) "-N ${escapeShellArg cfg.killHook}"
166
+
++ optionals cfg.enableDebugInfo [ "-d" ]
167
+
++ optionals cfg.enableNotifications [ "-n" ]
168
+
++ optionals (cfg.killHook != null) [ "-N ${escapeShellArg cfg.killHook}" ]