Skip to content

Commit

Permalink
nixos/opensmtpd: refactor to use tmpfiles to set up spool directories
Browse files Browse the repository at this point in the history
  • Loading branch information
flokli committed Nov 8, 2019
1 parent c62815d commit e349b6e
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions nixos/modules/services/mail/opensmtpd.nix
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ in {
};
};

systemd.tmpfiles.rules = [
"d /var/spool/smtpd 711 root - - -"
"d /var/spool/smtpd/offline 770 root smtpq - -"
"d /var/spool/smtpd/purge 700 smtpq root - -"
];

systemd.services.opensmtpd = let
procEnv = pkgs.buildEnv {
name = "opensmtpd-procs";
Expand All @@ -110,18 +116,6 @@ in {
in {
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
preStart = ''
mkdir -p /var/spool/smtpd
chmod 711 /var/spool/smtpd
mkdir -p /var/spool/smtpd/offline
chown root.smtpq /var/spool/smtpd/offline
chmod 770 /var/spool/smtpd/offline
mkdir -p /var/spool/smtpd/purge
chown smtpq.root /var/spool/smtpd/purge
chmod 700 /var/spool/smtpd/purge
'';
serviceConfig.ExecStart = "${cfg.package}/sbin/smtpd -d -f ${conf} ${args}";
environment.OPENSMTPD_PROC_PATH = "${procEnv}/libexec/opensmtpd";
};
Expand Down

0 comments on commit e349b6e

Please sign in to comment.