about summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorAaron Andersen <aaron@fosslib.net>2019-07-20 08:32:51 -0400
committerGitHub <noreply@github.com>2019-07-20 08:32:51 -0400
commit30920fbf691e65a9dc1f21b1bfc58c636245a72e (patch)
treeb916f1173b1cc33e4e71795e89ede4913acd429c /nixos
parentfaf884ca9b36d8a2cda19096c87d877d5f4da08d (diff)
parent1e23007dcda878503aa26813aca783a59e6f04b3 (diff)
downloadnixlib-30920fbf691e65a9dc1f21b1bfc58c636245a72e.tar
nixlib-30920fbf691e65a9dc1f21b1bfc58c636245a72e.tar.gz
nixlib-30920fbf691e65a9dc1f21b1bfc58c636245a72e.tar.bz2
nixlib-30920fbf691e65a9dc1f21b1bfc58c636245a72e.tar.lz
nixlib-30920fbf691e65a9dc1f21b1bfc58c636245a72e.tar.xz
nixlib-30920fbf691e65a9dc1f21b1bfc58c636245a72e.tar.zst
nixlib-30920fbf691e65a9dc1f21b1bfc58c636245a72e.zip
Merge pull request #64741 from dasJ/gitea-smtp-pw
nixos/gitea: Support SMTP without pw in the store
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/services/misc/gitea.nix18
1 files changed, 18 insertions, 0 deletions
diff --git a/nixos/modules/services/misc/gitea.nix b/nixos/modules/services/misc/gitea.nix
index 5a964e672ede..59c1c104b9b9 100644
--- a/nixos/modules/services/misc/gitea.nix
+++ b/nixos/modules/services/misc/gitea.nix
@@ -55,6 +55,11 @@ let
     [service]
     DISABLE_REGISTRATION = ${boolToString cfg.disableRegistration}
 
+    ${optionalString (cfg.mailerPasswordFile != null) ''
+      [mailer]
+      PASSWD = #mailerpass#
+    ''}
+
     ${cfg.extraConfig}
   '';
 in
@@ -255,6 +260,13 @@ in
         description = "Upper level of template and static files path.";
       };
 
+      mailerPasswordFile = mkOption {
+        type = types.nullOr types.str;
+        default = null;
+        example = "/var/lib/secrets/gitea/mailpw";
+        description = "Path to a file containing the SMTP password.";
+      };
+
       disableRegistration = mkEnableOption "the registration lock" // {
         description = ''
           By default any user can create an account on this <literal>gitea</literal> instance.
@@ -344,9 +356,15 @@ in
           KEY="$(head -n1 ${secretKey})"
           DBPASS="$(head -n1 ${cfg.database.passwordFile})"
           JWTSECRET="$(head -n1 ${jwtSecret})"
+          ${if (cfg.mailerPasswordFile == null) then ''
+            MAILERPASSWORD="#mailerpass#"
+          '' else ''
+            MAILERPASSWORD="$(head -n1 ${cfg.mailerPasswordFile} || :)"
+          ''}
           sed -e "s,#secretkey#,$KEY,g" \
               -e "s,#dbpass#,$DBPASS,g" \
               -e "s,#jwtsecet#,$JWTSECET,g" \
+              -e "s,#mailerpass#,$MAILERPASSWORD,g" \
               -i ${runConfig}
           chmod 640 ${runConfig} ${secretKey} ${jwtSecret}
         ''}