]>
Commit | Line | Data |
---|---|---|
ef43c362 IB |
1 | { |
2 | inputs.opendmarc = { | |
d533f938 | 3 | url = "path:../../opendmarc"; |
ef43c362 | 4 | }; |
da30ae4f | 5 | inputs.secrets = { |
d533f938 | 6 | url = "path:../../secrets"; |
da30ae4f | 7 | }; |
27dd65fc | 8 | inputs.files-watcher = { |
d533f938 | 9 | url = "path:../../files-watcher"; |
27dd65fc IB |
10 | }; |
11 | inputs.my-lib = { | |
d533f938 | 12 | url = "path:../../lib"; |
27dd65fc | 13 | }; |
5e2ec9fb IB |
14 | inputs.nix-lib.url = "github:NixOS/nixpkgs"; |
15 | ||
ef43c362 | 16 | description = "Private configuration for opendmarc"; |
da30ae4f | 17 | outputs = { self, nix-lib, opendmarc, my-lib, files-watcher, secrets }: |
ef43c362 | 18 | let |
27dd65fc | 19 | cfg = name': { config, lib, pkgs, name, ... }: { |
910c2e9e IB |
20 | imports = [ |
21 | (my-lib.lib.withNarKey files-watcher "nixosModule") | |
22 | (my-lib.lib.withNarKey opendmarc "nixosModule") | |
da30ae4f | 23 | (my-lib.lib.withNarKey secrets "nixosModule") |
910c2e9e | 24 | ]; |
27dd65fc IB |
25 | config = lib.mkIf (name == name') { |
26 | users.users."${config.services.opendmarc.user}".extraGroups = [ "keys" ]; | |
27 | systemd.services.opendmarc.serviceConfig.Slice = "mail.slice"; | |
28 | services.opendmarc = { | |
29 | enable = true; | |
910c2e9e | 30 | socket = "/run/opendmarc/opendmarc.sock"; |
27dd65fc IB |
31 | configFile = pkgs.writeText "opendmarc.conf" '' |
32 | AuthservID HOSTNAME | |
33 | FailureReports false | |
34 | FailureReportsBcc postmaster@immae.eu | |
35 | FailureReportsOnNone true | |
36 | FailureReportsSentBy postmaster@immae.eu | |
37 | IgnoreAuthenticatedClients true | |
38 | IgnoreHosts ${config.secrets.fullPaths."opendmarc/ignore.hosts"} | |
39 | SoftwareHeader true | |
40 | SPFIgnoreResults true | |
41 | SPFSelfValidate true | |
42 | UMask 002 | |
43 | ''; | |
44 | group = config.services.postfix.group; | |
45 | }; | |
46 | services.filesWatcher.opendmarc = { | |
47 | restart = true; | |
48 | paths = [ | |
49 | config.secrets.fullPaths."opendmarc/ignore.hosts" | |
50 | ]; | |
51 | }; | |
4c4652aa IB |
52 | secrets.keys = { |
53 | "opendmarc/ignore.hosts" = { | |
27dd65fc IB |
54 | user = config.services.opendmarc.user; |
55 | group = config.services.opendmarc.group; | |
56 | permissions = "0400"; | |
57 | text = let | |
58 | mxes = lib.attrsets.filterAttrs | |
59 | (n: v: v.mx.enable) | |
60 | config.myEnv.servers; | |
61 | in | |
62 | builtins.concatStringsSep "\n" ([ | |
63 | config.myEnv.mail.dmarc.ignore_hosts | |
64 | ] ++ lib.mapAttrsToList (n: v: v.fqdn) mxes); | |
4c4652aa IB |
65 | }; |
66 | }; | |
ef43c362 | 67 | }; |
ef43c362 IB |
68 | }; |
69 | in | |
70 | opendmarc.outputs // | |
5e2ec9fb | 71 | { nixosModules = opendmarc.nixosModules or {} // nix-lib.lib.genAttrs ["eldiron" "backup-2"] cfg; }; |
ef43c362 IB |
72 | } |
73 |