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