3
0
Fork 0
forked from mirrors/nixpkgs

Merge pull request #64741 from dasJ/gitea-smtp-pw

nixos/gitea: Support SMTP without pw in the store
This commit is contained in:
Aaron Andersen 2019-07-20 08:32:51 -04:00 committed by GitHub
commit 30920fbf69
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -55,6 +55,11 @@ let
[service] [service]
DISABLE_REGISTRATION = ${boolToString cfg.disableRegistration} DISABLE_REGISTRATION = ${boolToString cfg.disableRegistration}
${optionalString (cfg.mailerPasswordFile != null) ''
[mailer]
PASSWD = #mailerpass#
''}
${cfg.extraConfig} ${cfg.extraConfig}
''; '';
in in
@ -255,6 +260,13 @@ in
description = "Upper level of template and static files path."; 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" // { disableRegistration = mkEnableOption "the registration lock" // {
description = '' description = ''
By default any user can create an account on this <literal>gitea</literal> instance. By default any user can create an account on this <literal>gitea</literal> instance.
@ -344,9 +356,15 @@ in
KEY="$(head -n1 ${secretKey})" KEY="$(head -n1 ${secretKey})"
DBPASS="$(head -n1 ${cfg.database.passwordFile})" DBPASS="$(head -n1 ${cfg.database.passwordFile})"
JWTSECRET="$(head -n1 ${jwtSecret})" JWTSECRET="$(head -n1 ${jwtSecret})"
${if (cfg.mailerPasswordFile == null) then ''
MAILERPASSWORD="#mailerpass#"
'' else ''
MAILERPASSWORD="$(head -n1 ${cfg.mailerPasswordFile} || :)"
''}
sed -e "s,#secretkey#,$KEY,g" \ sed -e "s,#secretkey#,$KEY,g" \
-e "s,#dbpass#,$DBPASS,g" \ -e "s,#dbpass#,$DBPASS,g" \
-e "s,#jwtsecet#,$JWTSECET,g" \ -e "s,#jwtsecet#,$JWTSECET,g" \
-e "s,#mailerpass#,$MAILERPASSWORD,g" \
-i ${runConfig} -i ${runConfig}
chmod 640 ${runConfig} ${secretKey} ${jwtSecret} chmod 640 ${runConfig} ${secretKey} ${jwtSecret}
''} ''}