X-Git-Url: https://git.immae.eu/?p=perso%2FImmae%2FConfig%2FNix.git;a=blobdiff_plain;f=flakes%2Fprivate%2Fopendmarc%2Fflake.nix;h=7e9e8eb4d5ea117eee2710c0ba94e502ea67af6b;hp=e2575e7f56d7089b5798fc6e530415637d4b95c4;hb=1a64deeb894dc95e2645a75771732c6cc53a79ad;hpb=fa25ffd4583cc362075cd5e1b4130f33306103f0 diff --git a/flakes/private/opendmarc/flake.nix b/flakes/private/opendmarc/flake.nix index e2575e7..7e9e8eb 100644 --- a/flakes/private/opendmarc/flake.nix +++ b/flakes/private/opendmarc/flake.nix @@ -1,77 +1,62 @@ { - inputs.opendmarc = { - path = "../../opendmarc"; - type = "path"; - }; - inputs.secrets = { - path = "../../secrets"; - type = "path"; - }; - inputs.files-watcher = { - path = "../../files-watcher"; - type = "path"; - }; - inputs.my-lib = { - path = "../../lib"; - type = "path"; - }; - inputs.nix-lib.url = "github:NixOS/nixpkgs"; + inputs.opendmarc.url = "path:../../opendmarc"; + inputs.environment.url = "path:../environment"; + inputs.secrets.url = "path:../../secrets"; + inputs.files-watcher.url = "path:../../files-watcher"; description = "Private configuration for opendmarc"; - outputs = { self, nix-lib, opendmarc, my-lib, files-watcher, secrets }: - let - cfg = name': { config, lib, pkgs, name, ... }: { - imports = [ - (my-lib.lib.withNarKey files-watcher "nixosModule") - (my-lib.lib.withNarKey opendmarc "nixosModule") - (my-lib.lib.withNarKey secrets "nixosModule") - ]; - config = lib.mkIf (name == name') { - users.users."${config.services.opendmarc.user}".extraGroups = [ "keys" ]; - systemd.services.opendmarc.serviceConfig.Slice = "mail.slice"; - services.opendmarc = { - enable = true; - socket = "/run/opendmarc/opendmarc.sock"; - configFile = pkgs.writeText "opendmarc.conf" '' - AuthservID HOSTNAME - FailureReports false - FailureReportsBcc postmaster@immae.eu - FailureReportsOnNone true - FailureReportsSentBy postmaster@immae.eu - IgnoreAuthenticatedClients true - IgnoreHosts ${config.secrets.fullPaths."opendmarc/ignore.hosts"} - SoftwareHeader true - SPFIgnoreResults true - SPFSelfValidate true - UMask 002 - ''; - group = config.services.postfix.group; - }; - services.filesWatcher.opendmarc = { - restart = true; - paths = [ - config.secrets.fullPaths."opendmarc/ignore.hosts" - ]; - }; - secrets.keys = { - "opendmarc/ignore.hosts" = { - user = config.services.opendmarc.user; - group = config.services.opendmarc.group; - permissions = "0400"; - text = let - mxes = lib.attrsets.filterAttrs - (n: v: v.mx.enable) - config.myEnv.servers; - in - builtins.concatStringsSep "\n" ([ - config.myEnv.mail.dmarc.ignore_hosts - ] ++ lib.mapAttrsToList (n: v: v.fqdn) mxes); - }; + outputs = { self, environment, opendmarc, files-watcher, secrets }: { + nixosModule = self.nixosModules.opendmarc; + nixosModules.opendmarc = { config, lib, pkgs, ... }: { + imports = [ + environment.nixosModule + files-watcher.nixosModule + opendmarc.nixosModule + secrets.nixosModule + ]; + config = { + users.users."${config.services.opendmarc.user}".extraGroups = [ "keys" ]; + systemd.services.opendmarc.serviceConfig.Slice = "mail.slice"; + services.opendmarc = { + enable = true; + socket = "/run/opendmarc/opendmarc.sock"; + configFile = pkgs.writeText "opendmarc.conf" '' + AuthservID HOSTNAME + FailureReports false + FailureReportsBcc postmaster@immae.eu + FailureReportsOnNone true + FailureReportsSentBy postmaster@immae.eu + IgnoreAuthenticatedClients true + IgnoreHosts ${config.secrets.fullPaths."opendmarc/ignore.hosts"} + SoftwareHeader true + SPFIgnoreResults true + SPFSelfValidate true + UMask 002 + ''; + group = config.services.postfix.group; + }; + services.filesWatcher.opendmarc = { + restart = true; + paths = [ + config.secrets.fullPaths."opendmarc/ignore.hosts" + ]; + }; + secrets.keys = { + "opendmarc/ignore.hosts" = { + user = config.services.opendmarc.user; + group = config.services.opendmarc.group; + permissions = "0400"; + text = let + mxes = lib.attrsets.filterAttrs + (n: v: v.mx.enable) + config.myEnv.servers; + in + builtins.concatStringsSep "\n" ([ + config.myEnv.mail.dmarc.ignore_hosts + ] ++ lib.mapAttrsToList (n: v: v.fqdn) mxes); }; }; }; - in - opendmarc.outputs // - { nixosModules = opendmarc.nixosModules or {} // nix-lib.lib.genAttrs ["eldiron" "backup-2"] cfg; }; + }; + }; } -