1 { config, lib, pkgs, ... }:
7 cfg = config.services.opendmarc;
9 defaultSock = "local:/run/opendmarc/opendmarc.sock";
13 ] ++ optionals (cfg.configFile != null) [ "-c" cfg.configFile ];
21 services.opendmarc = {
26 description = "Whether to enable the OpenDMARC sender authentication system.";
31 default = defaultSock;
32 description = "Socket which is used for communication with OpenDMARC.";
37 default = "opendmarc";
38 description = "User for the daemon.";
43 default = "opendmarc";
44 description = "Group for the daemon.";
47 configFile = mkOption {
48 type = types.nullOr types.path;
50 description = "Additional OpenDMARC configuration.";
60 config = mkIf cfg.enable {
62 users.users = optionalAttrs (cfg.user == "opendmarc") {
65 uid = config.ids.uids.opendmarc;
69 users.groups = optionalAttrs (cfg.group == "opendmarc") {
71 gid = config.ids.gids.opendmarc;
75 environment.systemPackages = [ pkgs.opendmarc ];
77 systemd.services.opendmarc = {
78 description = "OpenDMARC daemon";
79 after = [ "network.target" ];
80 wantedBy = [ "multi-user.target" ];
83 ExecStart = "${pkgs.opendmarc}/bin/opendmarc ${escapeShellArgs args}";
86 RuntimeDirectory = optional (cfg.socket == defaultSock) "opendmarc";
87 PermissionsStartOnly = true;