From ab0bfdbfe2f1ae1335c24546b4d9e348b67ba421 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Sat, 10 Aug 2024 18:17:32 +0200 Subject: [PATCH] nixos/opendkim: add expandable settings option (cherry picked from commit 1414b222f52ba757b6af721b9fba0d23c957dab2) --- nixos/modules/services/mail/opendkim.nix | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/nixos/modules/services/mail/opendkim.nix b/nixos/modules/services/mail/opendkim.nix index c4ca4fa94aca..0784c7547ba1 100644 --- a/nixos/modules/services/mail/opendkim.nix +++ b/nixos/modules/services/mail/opendkim.nix @@ -64,10 +64,19 @@ in { description = "Selector to use when signing."; }; + # TODO: deprecate this? configFile = lib.mkOption { type = lib.types.nullOr lib.types.path; default = null; - description = "Additional opendkim configuration."; + description = "Additional opendkim configuration as a file."; + }; + + settings = lib.mkOption { + type = with lib.types; submodule { + freeformType = attrsOf str; + }; + default = { }; + description = "Additional opendkim configuration"; }; }; }; @@ -86,6 +95,9 @@ in { environment.systemPackages = [ pkgs.opendkim ]; + services.opendkim.configFile = lib.mkIf (cfg.settings != { }) (pkgs.writeText "opendkim.conf" + (lib.concatStringsSep "\n" (lib.mapAttrsToList (name: value: "${name} ${value}") cfg.settings))); + systemd.tmpfiles.rules = [ "d '${cfg.keyPath}' - ${cfg.user} ${cfg.group} - -" ];