summary refs log tree commit diff
path: root/modules/programs/ssmtp.nix
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2009-05-27 23:59:14 +0000
committerEelco Dolstra <eelco.dolstra@logicblox.com>2009-05-27 23:59:14 +0000
commit2d7beac3773e929093a06099c328d67836f5dab6 (patch)
tree173d366623f6d47f08ee114f5cf681c52d2edb29 /modules/programs/ssmtp.nix
parent2c34a4b8c0ce68aeda216576008066af0ecf1f19 (diff)
downloadnixpkgs-2d7beac3773e929093a06099c328d67836f5dab6.tar
nixpkgs-2d7beac3773e929093a06099c328d67836f5dab6.tar.gz
nixpkgs-2d7beac3773e929093a06099c328d67836f5dab6.tar.bz2
nixpkgs-2d7beac3773e929093a06099c328d67836f5dab6.tar.lz
nixpkgs-2d7beac3773e929093a06099c328d67836f5dab6.tar.xz
nixpkgs-2d7beac3773e929093a06099c328d67836f5dab6.tar.zst
nixpkgs-2d7beac3773e929093a06099c328d67836f5dab6.zip
* New directory modules/programs that contains system-wide
  configuration for specific programs.  For instance, ssh.nix provides
  the configuration for the SSH client; ssmtp.nix provides the
  configuration for the `ssmtp' MTA.

svn path=/nixos/branches/modular-nixos/; revision=15757
Diffstat (limited to 'modules/programs/ssmtp.nix')
-rw-r--r--modules/programs/ssmtp.nix91
1 files changed, 91 insertions, 0 deletions
diff --git a/modules/programs/ssmtp.nix b/modules/programs/ssmtp.nix
new file mode 100644
index 00000000000..a0ecf763528
--- /dev/null
+++ b/modules/programs/ssmtp.nix
@@ -0,0 +1,91 @@
+# Configuration for `ssmtp', a trivial mail transfer agent that can
+# replace sendmail/postfix on simple systems.  It delivers email
+# directly to an SMTP server defined in its configuration file, wihout
+# queueing mail locally.
+
+{config, pkgs, ...}:
+
+with pkgs.lib;
+
+let
+
+  options = {
+
+    networking.defaultMailServer = {
+
+      directDelivery = mkOption {
+        default = false;
+        example = true;
+        description = "
+          Use the trivial Mail Transfer Agent (MTA)
+          <command>ssmtp</command> package to allow programs to send
+          e-mail.  If you don't want to run a ``real'' MTA like
+          <command>sendmail</command> or <command>postfix</command> on
+          your machine, set this option to <literal>true</literal>, and
+          set the option
+          <option>networking.defaultMailServer.hostName</option> to the
+          host name of your preferred mail server.
+        ";
+      };
+
+      hostName = mkOption {
+        example = "mail.example.org";
+        description = "
+          The host name of the default mail server to use to deliver
+          e-mail.
+        ";
+      };
+
+      domain = mkOption {
+        default = "";
+        example = "example.org";
+        description = "
+          The domain from which mail will appear to be sent.
+        ";
+      };
+
+      useTLS = mkOption {
+        default = false;
+        example = true;
+        description = "
+          Whether TLS should be used to connect to the default mail
+          server.
+        ";
+      };
+
+      useSTARTTLS = mkOption {
+        default = false;
+        example = true;
+        description = "
+          Whether the STARTTLS should be used to connect to the default
+          mail server.  (This is needed for TLS-capable mail servers
+          running on the default SMTP port 25.)
+        ";
+      };
+
+    };
+
+  };
+
+  cfg = config.networking.defaultMailServer;
+
+in
+
+mkIf cfg.directDelivery {
+  require = [options];
+
+  environment.etc =
+    [ { source = pkgs.writeText "ssmtp.conf" ''
+          MailHub=${cfg.hostName}
+          FromLineOverride=YES
+          ${if cfg.domain != "" then "rewriteDomain=${cfg.domain}" else ""}
+          UseTLS=${if cfg.useTLS then "YES" else "NO"}
+          UseSTARTTLS=${if cfg.useSTARTTLS then "YES" else "NO"}
+          #Debug=YES
+        '';
+        target = "ssmtp/ssmtp.conf";
+      }
+    ];
+
+  environment.extraPackages = [pkgs.ssmtp];
+}