services.earlyoom: set package option
Also add AndersonTorres as maintainer.
This commit is contained in:
parent
7b7ccd525c
commit
cef01a232d
1 changed files with 26 additions and 13 deletions
|
@ -4,15 +4,29 @@ let
|
||||||
cfg = config.services.earlyoom;
|
cfg = config.services.earlyoom;
|
||||||
|
|
||||||
inherit (lib)
|
inherit (lib)
|
||||||
mkDefault mkEnableOption mkIf mkOption types
|
concatStringsSep
|
||||||
mkRemovedOptionModule literalExpression
|
escapeShellArg
|
||||||
escapeShellArg concatStringsSep optional optionalString;
|
literalExpression
|
||||||
|
mkDefault
|
||||||
|
mkEnableOption
|
||||||
|
mkIf
|
||||||
|
mkOption
|
||||||
|
mkPackageOption
|
||||||
|
mkRemovedOptionModule
|
||||||
|
optionalString
|
||||||
|
optionals
|
||||||
|
types;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
meta = {
|
||||||
|
maintainers = with lib.maintainers; [ AndersonTorres ];
|
||||||
|
};
|
||||||
|
|
||||||
options.services.earlyoom = {
|
options.services.earlyoom = {
|
||||||
enable = mkEnableOption "early out of memory killing";
|
enable = mkEnableOption "early out of memory killing";
|
||||||
|
|
||||||
|
package = mkPackageOption pkgs "earlyoom" { };
|
||||||
|
|
||||||
freeMemThreshold = mkOption {
|
freeMemThreshold = mkOption {
|
||||||
type = types.ints.between 1 100;
|
type = types.ints.between 1 100;
|
||||||
default = 10;
|
default = 10;
|
||||||
|
@ -138,22 +152,21 @@ in
|
||||||
systemd.services.earlyoom = {
|
systemd.services.earlyoom = {
|
||||||
description = "Early OOM Daemon for Linux";
|
description = "Early OOM Daemon for Linux";
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
path = optional cfg.enableNotifications pkgs.dbus;
|
path = optionals cfg.enableNotifications [ pkgs.dbus ];
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
StandardError = "journal";
|
StandardError = "journal";
|
||||||
ExecStart = concatStringsSep " " ([
|
ExecStart = concatStringsSep " " ([
|
||||||
"${pkgs.earlyoom}/bin/earlyoom"
|
"${lib.getExe cfg.package}"
|
||||||
("-m ${toString cfg.freeMemThreshold}"
|
("-m ${toString cfg.freeMemThreshold}"
|
||||||
+ optionalString (cfg.freeMemKillThreshold != null) ",${toString cfg.freeMemKillThreshold}")
|
+ optionalString (cfg.freeMemKillThreshold != null) ",${toString cfg.freeMemKillThreshold}")
|
||||||
("-s ${toString cfg.freeSwapThreshold}"
|
("-s ${toString cfg.freeSwapThreshold}"
|
||||||
+ optionalString (cfg.freeSwapKillThreshold != null) ",${toString cfg.freeSwapKillThreshold}")
|
+ optionalString (cfg.freeSwapKillThreshold != null) ",${toString cfg.freeSwapKillThreshold}")
|
||||||
"-r ${toString cfg.reportInterval}"
|
"-r ${toString cfg.reportInterval}"
|
||||||
]
|
]
|
||||||
++ optional cfg.enableDebugInfo "-d"
|
++ optionals cfg.enableDebugInfo [ "-d" ]
|
||||||
++ optional cfg.enableNotifications "-n"
|
++ optionals cfg.enableNotifications [ "-n" ]
|
||||||
++ optional (cfg.killHook != null) "-N ${escapeShellArg cfg.killHook}"
|
++ optionals (cfg.killHook != null) [ "-N ${escapeShellArg cfg.killHook}" ]
|
||||||
++ cfg.extraArgs
|
++ cfg.extraArgs);
|
||||||
);
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue