From eacd58dfea82c58c2cc4ae8a4539936217e8fef7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Sat, 10 Aug 2024 20:21:57 +0200 Subject: [PATCH] nixos/opendkim: put config file under standard location (cherry picked from commit f497159195ef8c30849a8cd1df0719350ce8c5b4) --- nixos/modules/services/mail/opendkim.nix | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/nixos/modules/services/mail/opendkim.nix b/nixos/modules/services/mail/opendkim.nix index 0784c7547ba1..0aed4d9bee01 100644 --- a/nixos/modules/services/mail/opendkim.nix +++ b/nixos/modules/services/mail/opendkim.nix @@ -12,6 +12,8 @@ let "-s" cfg.selector ] ++ lib.optionals (cfg.configFile != null) [ "-x" cfg.configFile ]; + configFile = pkgs.writeText "opendkim.conf" + (lib.concatStringsSep "\n" (lib.mapAttrsToList (name: value: "${name} ${value}") cfg.settings)); in { imports = [ (lib.mkRenamedOptionModule [ "services" "opendkim" "keyFile" ] [ "services" "opendkim" "keyPath" ]) @@ -93,10 +95,14 @@ in { opendkim.gid = config.ids.gids.opendkim; }; - environment.systemPackages = [ pkgs.opendkim ]; + environment = { + etc = lib.mkIf (cfg.settings != { }) { + "opendkim/opendkim.conf".source = configFile; + }; + 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))); + services.opendkim.configFile = lib.mkIf (cfg.settings != { }) configFile; systemd.tmpfiles.rules = [ "d '${cfg.keyPath}' - ${cfg.user} ${cfg.group} - -"