nixos/services.journalwatch: remove with lib;
This commit is contained in:
parent
0470d7f52f
commit
5bc3fb4949
@ -1,6 +1,4 @@
|
|||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
with lib;
|
|
||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.services.journalwatch;
|
cfg = config.services.journalwatch;
|
||||||
user = "journalwatch";
|
user = "journalwatch";
|
||||||
@ -15,7 +13,7 @@ let
|
|||||||
priority = ${toString cfg.priority}
|
priority = ${toString cfg.priority}
|
||||||
mail_from = ${cfg.mailFrom}
|
mail_from = ${cfg.mailFrom}
|
||||||
''
|
''
|
||||||
+ optionalString (cfg.mailTo != null) ''
|
+ lib.optionalString (cfg.mailTo != null) ''
|
||||||
mail_to = ${cfg.mailTo}
|
mail_to = ${cfg.mailTo}
|
||||||
''
|
''
|
||||||
+ cfg.extraConfig);
|
+ cfg.extraConfig);
|
||||||
@ -27,7 +25,7 @@ let
|
|||||||
'';
|
'';
|
||||||
|
|
||||||
# empty line at the end needed to to separate the blocks
|
# empty line at the end needed to to separate the blocks
|
||||||
mkPatterns = filterBlocks: concatStringsSep "\n" (map (block: ''
|
mkPatterns = filterBlocks: lib.concatStringsSep "\n" (map (block: ''
|
||||||
${block.match}
|
${block.match}
|
||||||
${block.filters}
|
${block.filters}
|
||||||
|
|
||||||
@ -48,18 +46,18 @@ let
|
|||||||
in {
|
in {
|
||||||
options = {
|
options = {
|
||||||
services.journalwatch = {
|
services.journalwatch = {
|
||||||
enable = mkOption {
|
enable = lib.mkOption {
|
||||||
type = types.bool;
|
type = lib.types.bool;
|
||||||
default = false;
|
default = false;
|
||||||
description = ''
|
description = ''
|
||||||
If enabled, periodically check the journal with journalwatch and report the results by mail.
|
If enabled, periodically check the journal with journalwatch and report the results by mail.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
package = mkPackageOption pkgs "journalwatch" { };
|
package = lib.mkPackageOption pkgs "journalwatch" { };
|
||||||
|
|
||||||
priority = mkOption {
|
priority = lib.mkOption {
|
||||||
type = types.int;
|
type = lib.types.int;
|
||||||
default = 6;
|
default = 6;
|
||||||
description = ''
|
description = ''
|
||||||
Lowest priority of message to be considered.
|
Lowest priority of message to be considered.
|
||||||
@ -73,33 +71,33 @@ in {
|
|||||||
# HACK: this is a workaround for journalwatch's usage of socket.getfqdn() which always returns localhost if
|
# HACK: this is a workaround for journalwatch's usage of socket.getfqdn() which always returns localhost if
|
||||||
# there's an alias for the localhost on a separate line in /etc/hosts, or take for ages if it's not present and
|
# there's an alias for the localhost on a separate line in /etc/hosts, or take for ages if it's not present and
|
||||||
# then return something right-ish in the direction of /etc/hostname. Just bypass it completely.
|
# then return something right-ish in the direction of /etc/hostname. Just bypass it completely.
|
||||||
mailFrom = mkOption {
|
mailFrom = lib.mkOption {
|
||||||
type = types.str;
|
type = lib.types.str;
|
||||||
default = "journalwatch@${config.networking.hostName}";
|
default = "journalwatch@${config.networking.hostName}";
|
||||||
defaultText = literalExpression ''"journalwatch@''${config.networking.hostName}"'';
|
defaultText = lib.literalExpression ''"journalwatch@''${config.networking.hostName}"'';
|
||||||
description = ''
|
description = ''
|
||||||
Mail address to send journalwatch reports from.
|
Mail address to send journalwatch reports from.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
mailTo = mkOption {
|
mailTo = lib.mkOption {
|
||||||
type = types.nullOr types.str;
|
type = lib.types.nullOr lib.types.str;
|
||||||
default = null;
|
default = null;
|
||||||
description = ''
|
description = ''
|
||||||
Mail address to send journalwatch reports to.
|
Mail address to send journalwatch reports to.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
mailBinary = mkOption {
|
mailBinary = lib.mkOption {
|
||||||
type = types.path;
|
type = lib.types.path;
|
||||||
default = "/run/wrappers/bin/sendmail";
|
default = "/run/wrappers/bin/sendmail";
|
||||||
description = ''
|
description = ''
|
||||||
Sendmail-compatible binary to be used to send the messages.
|
Sendmail-compatible binary to be used to send the messages.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
extraConfig = mkOption {
|
extraConfig = lib.mkOption {
|
||||||
type = types.str;
|
type = lib.types.str;
|
||||||
default = "";
|
default = "";
|
||||||
description = ''
|
description = ''
|
||||||
Extra lines to be added verbatim to the journalwatch/config configuration file.
|
Extra lines to be added verbatim to the journalwatch/config configuration file.
|
||||||
@ -108,11 +106,11 @@ in {
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
filterBlocks = mkOption {
|
filterBlocks = lib.mkOption {
|
||||||
type = types.listOf (types.submodule {
|
type = lib.types.listOf (lib.types.submodule {
|
||||||
options = {
|
options = {
|
||||||
match = mkOption {
|
match = lib.mkOption {
|
||||||
type = types.str;
|
type = lib.types.str;
|
||||||
example = "SYSLOG_IDENTIFIER = systemd";
|
example = "SYSLOG_IDENTIFIER = systemd";
|
||||||
description = ''
|
description = ''
|
||||||
Syntax: `field = value`
|
Syntax: `field = value`
|
||||||
@ -125,8 +123,8 @@ in {
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
filters = mkOption {
|
filters = lib.mkOption {
|
||||||
type = types.str;
|
type = lib.types.str;
|
||||||
example = ''
|
example = ''
|
||||||
(Stopped|Stopping|Starting|Started) .*
|
(Stopped|Stopping|Starting|Started) .*
|
||||||
(Reached target|Stopped target) .*
|
(Reached target|Stopped target) .*
|
||||||
@ -190,8 +188,8 @@ in {
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
interval = mkOption {
|
interval = lib.mkOption {
|
||||||
type = types.str;
|
type = lib.types.str;
|
||||||
default = "hourly";
|
default = "hourly";
|
||||||
description = ''
|
description = ''
|
||||||
How often to run journalwatch.
|
How often to run journalwatch.
|
||||||
@ -199,8 +197,8 @@ in {
|
|||||||
The format is described in systemd.time(7).
|
The format is described in systemd.time(7).
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
accuracy = mkOption {
|
accuracy = lib.mkOption {
|
||||||
type = types.str;
|
type = lib.types.str;
|
||||||
default = "10min";
|
default = "10min";
|
||||||
description = ''
|
description = ''
|
||||||
The time window around the interval in which the journalwatch run will be scheduled.
|
The time window around the interval in which the journalwatch run will be scheduled.
|
||||||
@ -211,7 +209,7 @@ in {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
|
|
||||||
users.users.${user} = {
|
users.users.${user} = {
|
||||||
isSystemUser = true;
|
isSystemUser = true;
|
||||||
@ -242,7 +240,7 @@ in {
|
|||||||
# requires a relative directory name to create beneath /var/lib
|
# requires a relative directory name to create beneath /var/lib
|
||||||
StateDirectory = user;
|
StateDirectory = user;
|
||||||
StateDirectoryMode = "0750";
|
StateDirectoryMode = "0750";
|
||||||
ExecStart = "${getExe cfg.package} mail";
|
ExecStart = "${lib.getExe cfg.package} mail";
|
||||||
# lowest CPU and IO priority, but both still in best-effort class to prevent starvation
|
# lowest CPU and IO priority, but both still in best-effort class to prevent starvation
|
||||||
Nice=19;
|
Nice=19;
|
||||||
IOSchedulingPriority=7;
|
IOSchedulingPriority=7;
|
||||||
|
Loading…
Reference in New Issue
Block a user