nixos/services.nullmailer: remove with lib;
This commit is contained in:
parent
2f79bd3b5c
commit
e75cd5f98a
@ -1,42 +1,39 @@
|
|||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
with lib;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
|
|
||||||
services.nullmailer = {
|
services.nullmailer = {
|
||||||
enable = mkOption {
|
enable = lib.mkOption {
|
||||||
type = types.bool;
|
type = lib.types.bool;
|
||||||
default = false;
|
default = false;
|
||||||
description = "Whether to enable nullmailer daemon.";
|
description = "Whether to enable nullmailer daemon.";
|
||||||
};
|
};
|
||||||
|
|
||||||
user = mkOption {
|
user = lib.mkOption {
|
||||||
type = types.str;
|
type = lib.types.str;
|
||||||
default = "nullmailer";
|
default = "nullmailer";
|
||||||
description = ''
|
description = ''
|
||||||
User to use to run nullmailer-send.
|
User to use to run nullmailer-send.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
group = mkOption {
|
group = lib.mkOption {
|
||||||
type = types.str;
|
type = lib.types.str;
|
||||||
default = "nullmailer";
|
default = "nullmailer";
|
||||||
description = ''
|
description = ''
|
||||||
Group to use to run nullmailer-send.
|
Group to use to run nullmailer-send.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
setSendmail = mkOption {
|
setSendmail = lib.mkOption {
|
||||||
type = types.bool;
|
type = lib.types.bool;
|
||||||
default = true;
|
default = true;
|
||||||
description = "Whether to set the system sendmail to nullmailer's.";
|
description = "Whether to set the system sendmail to nullmailer's.";
|
||||||
};
|
};
|
||||||
|
|
||||||
remotesFile = mkOption {
|
remotesFile = lib.mkOption {
|
||||||
type = types.nullOr types.str;
|
type = lib.types.nullOr lib.types.str;
|
||||||
default = null;
|
default = null;
|
||||||
description = ''
|
description = ''
|
||||||
Path to the `remotes` control file. This file contains a
|
Path to the `remotes` control file. This file contains a
|
||||||
@ -48,8 +45,8 @@ with lib;
|
|||||||
};
|
};
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
adminaddr = mkOption {
|
adminaddr = lib.mkOption {
|
||||||
type = types.nullOr types.str;
|
type = lib.types.nullOr lib.types.str;
|
||||||
default = null;
|
default = null;
|
||||||
description = ''
|
description = ''
|
||||||
If set, all recipients to users at either "localhost" (the literal string)
|
If set, all recipients to users at either "localhost" (the literal string)
|
||||||
@ -61,16 +58,16 @@ with lib;
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
allmailfrom = mkOption {
|
allmailfrom = lib.mkOption {
|
||||||
type = types.nullOr types.str;
|
type = lib.types.nullOr lib.types.str;
|
||||||
default = null;
|
default = null;
|
||||||
description = ''
|
description = ''
|
||||||
If set, content will override the envelope sender on all messages.
|
If set, content will override the envelope sender on all messages.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
defaultdomain = mkOption {
|
defaultdomain = lib.mkOption {
|
||||||
type = types.nullOr types.str;
|
type = lib.types.nullOr lib.types.str;
|
||||||
default = null;
|
default = null;
|
||||||
description = ''
|
description = ''
|
||||||
The content of this attribute is appended to any host name that
|
The content of this attribute is appended to any host name that
|
||||||
@ -80,8 +77,8 @@ with lib;
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
defaulthost = mkOption {
|
defaulthost = lib.mkOption {
|
||||||
type = types.nullOr types.str;
|
type = lib.types.nullOr lib.types.str;
|
||||||
default = null;
|
default = null;
|
||||||
description = ''
|
description = ''
|
||||||
The content of this attribute is appended to any address that
|
The content of this attribute is appended to any address that
|
||||||
@ -90,8 +87,8 @@ with lib;
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
doublebounceto = mkOption {
|
doublebounceto = lib.mkOption {
|
||||||
type = types.nullOr types.str;
|
type = lib.types.nullOr lib.types.str;
|
||||||
default = null;
|
default = null;
|
||||||
description = ''
|
description = ''
|
||||||
If the original sender was empty (the original message was a
|
If the original sender was empty (the original message was a
|
||||||
@ -100,8 +97,8 @@ with lib;
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
helohost = mkOption {
|
helohost = lib.mkOption {
|
||||||
type = types.nullOr types.str;
|
type = lib.types.nullOr lib.types.str;
|
||||||
default = null;
|
default = null;
|
||||||
description = ''
|
description = ''
|
||||||
Sets the environment variable $HELOHOST which is used by the
|
Sets the environment variable $HELOHOST which is used by the
|
||||||
@ -110,8 +107,8 @@ with lib;
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
idhost = mkOption {
|
idhost = lib.mkOption {
|
||||||
type = types.nullOr types.str;
|
type = lib.types.nullOr lib.types.str;
|
||||||
default = null;
|
default = null;
|
||||||
description = ''
|
description = ''
|
||||||
The content of this attribute is used when building the message-id
|
The content of this attribute is used when building the message-id
|
||||||
@ -119,8 +116,8 @@ with lib;
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
maxpause = mkOption {
|
maxpause = lib.mkOption {
|
||||||
type = with types; nullOr (oneOf [ str int ]);
|
type = with lib.types; nullOr (oneOf [ str int ]);
|
||||||
default = null;
|
default = null;
|
||||||
description = ''
|
description = ''
|
||||||
The maximum time to pause between successive queue runs, in seconds.
|
The maximum time to pause between successive queue runs, in seconds.
|
||||||
@ -128,8 +125,8 @@ with lib;
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
me = mkOption {
|
me = lib.mkOption {
|
||||||
type = types.nullOr types.str;
|
type = lib.types.nullOr lib.types.str;
|
||||||
default = null;
|
default = null;
|
||||||
description = ''
|
description = ''
|
||||||
The fully-qualifiled host name of the computer running nullmailer.
|
The fully-qualifiled host name of the computer running nullmailer.
|
||||||
@ -137,8 +134,8 @@ with lib;
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
pausetime = mkOption {
|
pausetime = lib.mkOption {
|
||||||
type = with types; nullOr (oneOf [ str int ]);
|
type = with lib.types; nullOr (oneOf [ str int ]);
|
||||||
default = null;
|
default = null;
|
||||||
description = ''
|
description = ''
|
||||||
The minimum time to pause between successive queue runs when there
|
The minimum time to pause between successive queue runs when there
|
||||||
@ -150,8 +147,8 @@ with lib;
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
remotes = mkOption {
|
remotes = lib.mkOption {
|
||||||
type = types.nullOr types.str;
|
type = lib.types.nullOr lib.types.str;
|
||||||
default = null;
|
default = null;
|
||||||
description = ''
|
description = ''
|
||||||
A list of remote servers to which to send each message. Each line
|
A list of remote servers to which to send each message. Each line
|
||||||
@ -167,8 +164,8 @@ with lib;
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
sendtimeout = mkOption {
|
sendtimeout = lib.mkOption {
|
||||||
type = with types; nullOr (oneOf [ str int ]);
|
type = with lib.types; nullOr (oneOf [ str int ]);
|
||||||
default = null;
|
default = null;
|
||||||
description = ''
|
description = ''
|
||||||
The time to wait for a remote module listed above to complete sending
|
The time to wait for a remote module listed above to complete sending
|
||||||
@ -183,7 +180,7 @@ with lib;
|
|||||||
|
|
||||||
config = let
|
config = let
|
||||||
cfg = config.services.nullmailer;
|
cfg = config.services.nullmailer;
|
||||||
in mkIf cfg.enable {
|
in lib.mkIf cfg.enable {
|
||||||
|
|
||||||
assertions = [
|
assertions = [
|
||||||
{ assertion = cfg.config.remotes == null || cfg.remotesFile == null;
|
{ assertion = cfg.config.remotes == null || cfg.remotesFile == null;
|
||||||
@ -194,10 +191,10 @@ with lib;
|
|||||||
environment = {
|
environment = {
|
||||||
systemPackages = [ pkgs.nullmailer ];
|
systemPackages = [ pkgs.nullmailer ];
|
||||||
etc = let
|
etc = let
|
||||||
validAttrs = lib.mapAttrs (_: toString) (filterAttrs (_: value: value != null) cfg.config);
|
validAttrs = lib.mapAttrs (_: toString) (lib.filterAttrs (_: value: value != null) cfg.config);
|
||||||
in
|
in
|
||||||
(foldl' (as: name: as // { "nullmailer/${name}".text = validAttrs.${name}; }) {} (attrNames validAttrs))
|
(lib.foldl' (as: name: as // { "nullmailer/${name}".text = validAttrs.${name}; }) {} (lib.attrNames validAttrs))
|
||||||
// optionalAttrs (cfg.remotesFile != null) { "nullmailer/remotes".source = cfg.remotesFile; };
|
// lib.optionalAttrs (cfg.remotesFile != null) { "nullmailer/remotes".source = cfg.remotesFile; };
|
||||||
};
|
};
|
||||||
|
|
||||||
users = {
|
users = {
|
||||||
@ -234,7 +231,7 @@ with lib;
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
services.mail.sendmailSetuidWrapper = mkIf cfg.setSendmail {
|
services.mail.sendmailSetuidWrapper = lib.mkIf cfg.setSendmail {
|
||||||
program = "sendmail";
|
program = "sendmail";
|
||||||
source = "${pkgs.nullmailer}/bin/sendmail";
|
source = "${pkgs.nullmailer}/bin/sendmail";
|
||||||
owner = cfg.user;
|
owner = cfg.user;
|
||||||
|
Loading…
Reference in New Issue
Block a user