summary refs log tree commit diff
diff options
context:
space:
mode:
authorpacien <pacien.trangirard@pacien.net>2020-12-02 16:40:58 +0100
committerpacien <pacien.trangirard@pacien.net>2020-12-02 16:41:06 +0100
commita2c4419636802218e2cac198ba1bb55a37b2feff (patch)
treeaa8030f7c4447d5f5d7158e8108ba7160dfa1dfd
parent5e402a3ab9beaf0dc3f5cdd7aa4a86bc90306bb8 (diff)
downloadnixpkgs-a2c4419636802218e2cac198ba1bb55a37b2feff.tar
nixpkgs-a2c4419636802218e2cac198ba1bb55a37b2feff.tar.gz
nixpkgs-a2c4419636802218e2cac198ba1bb55a37b2feff.tar.bz2
nixpkgs-a2c4419636802218e2cac198ba1bb55a37b2feff.tar.lz
nixpkgs-a2c4419636802218e2cac198ba1bb55a37b2feff.tar.xz
nixpkgs-a2c4419636802218e2cac198ba1bb55a37b2feff.tar.zst
nixpkgs-a2c4419636802218e2cac198ba1bb55a37b2feff.zip
nixos/ssmtp: fix configuration generator to accomodate ssmtp
This replaces `concatStringsSep "\n"` with the proper generator to make sure
that the generated configuration file ends with a trailing `\n`, which is
required by ssmtp's picky configuration parser to take the last configuration
key into account.

GitHub: closes #105704
-rw-r--r--nixos/modules/programs/ssmtp.nix13
1 files changed, 7 insertions, 6 deletions
diff --git a/nixos/modules/programs/ssmtp.nix b/nixos/modules/programs/ssmtp.nix
index 1f49ddc91bb..8039763facc 100644
--- a/nixos/modules/programs/ssmtp.nix
+++ b/nixos/modules/programs/ssmtp.nix
@@ -162,15 +162,16 @@ in
       (mkIf (cfg.authPassFile != null) { AuthPassFile = cfg.authPassFile; })
     ];
 
-    environment.etc."ssmtp/ssmtp.conf".source =
-      let
-        toStr = value:
+    # careful here: ssmtp REQUIRES all config lines to end with a newline char!
+    environment.etc."ssmtp/ssmtp.conf".text = with generators; toKeyValue {
+      mkKeyValue = mkKeyValueDefault {
+        mkValueString = value:
           if value == true then "YES"
           else if value == false then "NO"
-          else builtins.toString value
+          else mkValueStringDefault {} value
         ;
-      in
-        pkgs.writeText "ssmtp.conf" (concatStringsSep "\n" (mapAttrsToList (key: value: "${key}=${toStr value}") cfg.settings));
+      } "=";
+    } cfg.settings;
 
     environment.systemPackages = [pkgs.ssmtp];