Merge pull request #19874 from joachifm/opensmtpd-refactorings

Opensmtpd module refactorings
This commit is contained in:
Joachim F 2016-10-27 13:39:09 +02:00 committed by GitHub
commit 371a595f3c
1 changed files with 7 additions and 11 deletions

View File

@ -1,17 +1,16 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with pkgs;
with lib; with lib;
let let
cfg = config.services.opensmtpd; cfg = config.services.opensmtpd;
conf = writeText "smtpd.conf" cfg.serverConfiguration; conf = pkgs.writeText "smtpd.conf" cfg.serverConfiguration;
args = concatStringsSep " " cfg.extraServerArgs; args = concatStringsSep " " cfg.extraServerArgs;
sendmail = pkgs.runCommand "opensmtpd-sendmail" {} '' sendmail = pkgs.runCommand "opensmtpd-sendmail" {} ''
mkdir -p $out/bin mkdir -p $out/bin
ln -s ${opensmtpd}/sbin/smtpctl $out/bin/sendmail ln -s ${pkgs.opensmtpd}/sbin/smtpctl $out/bin/sendmail
''; '';
in { in {
@ -48,21 +47,19 @@ in {
}; };
serverConfiguration = mkOption { serverConfiguration = mkOption {
type = types.string; type = types.lines;
default = "";
example = '' example = ''
listen on lo listen on lo
accept for any deliver to lmtp localhost:24 accept for any deliver to lmtp localhost:24
''; '';
description = '' description = ''
The contents of the smtpd.conf configuration file. See the The contents of the smtpd.conf configuration file. See the
OpenSMTPD documentation for syntax information. If this option OpenSMTPD documentation for syntax information.
is left empty, the OpenSMTPD server will not start.
''; '';
}; };
procPackages = mkOption { procPackages = mkOption {
type = types.listOf types.path; type = types.listOf types.package;
default = []; default = [];
description = '' description = ''
Packages to search for filters, tables, queues, and schedulers. Packages to search for filters, tables, queues, and schedulers.
@ -100,12 +97,11 @@ in {
systemd.services.opensmtpd = let systemd.services.opensmtpd = let
procEnv = pkgs.buildEnv { procEnv = pkgs.buildEnv {
name = "opensmtpd-procs"; name = "opensmtpd-procs";
paths = [ opensmtpd ] ++ cfg.procPackages; paths = [ pkgs.opensmtpd ] ++ cfg.procPackages;
pathsToLink = [ "/libexec/opensmtpd" ]; pathsToLink = [ "/libexec/opensmtpd" ];
}; };
in { in {
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
wants = [ "network.target" ];
after = [ "network.target" ]; after = [ "network.target" ];
preStart = '' preStart = ''
mkdir -p /var/spool/smtpd mkdir -p /var/spool/smtpd