nixos/writefreely: add support for email smtp password + minor fixes (#458481)
This commit is contained in:
@@ -19,7 +19,7 @@ let
|
||||
optionalString
|
||||
;
|
||||
|
||||
inherit (pkgs) sqlite;
|
||||
inherit (pkgs) sqlite openssl;
|
||||
|
||||
format = pkgs.formats.ini {
|
||||
mkKeyValue =
|
||||
@@ -72,6 +72,10 @@ let
|
||||
pages_parent_dir = cfg.settings.server.pages_parent_dir or cfg.package.src;
|
||||
keys_parent_dir = cfg.settings.server.keys_parent_dir or cfg.stateDir;
|
||||
};
|
||||
|
||||
email = cfg.settings.email or { } // {
|
||||
smtp_password = "#smtppass#";
|
||||
};
|
||||
};
|
||||
|
||||
configFile = format.generate "config.ini" settings;
|
||||
@@ -104,9 +108,15 @@ let
|
||||
db_pass=${
|
||||
optionalString (cfg.database.passwordFile != null) "$(head -n1 ${cfg.database.passwordFile})"
|
||||
}
|
||||
smtp_pass=${
|
||||
optionalString (
|
||||
cfg.email.smtpPasswordFile != null
|
||||
) ''$(printf '%s\n' "$(head -n1 ${cfg.email.smtpPasswordFile})" | sed -e 's/[\/&]/\\&/g')''
|
||||
}
|
||||
|
||||
cp -f ${configFile} '${cfg.stateDir}/config.ini'
|
||||
sed -e "s,#dbpass#,$db_pass,g" -i '${cfg.stateDir}/config.ini'
|
||||
sed -e "s,#smtppass#,$smtp_pass,g" -i '${cfg.stateDir}/config.ini'
|
||||
chmod 440 '${cfg.stateDir}/config.ini'
|
||||
|
||||
${text}
|
||||
@@ -123,7 +133,7 @@ let
|
||||
--silent \
|
||||
--raw \
|
||||
--skip-column-names \
|
||||
--execute "$1" \
|
||||
--execute "$1"
|
||||
)
|
||||
|
||||
echo $result
|
||||
@@ -291,6 +301,14 @@ in
|
||||
};
|
||||
};
|
||||
|
||||
email = {
|
||||
smtpPasswordFile = mkOption {
|
||||
type = types.nullOr types.path;
|
||||
default = null;
|
||||
description = "The file to load the password for the smtp email server.";
|
||||
};
|
||||
};
|
||||
|
||||
nginx = {
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
@@ -356,6 +374,8 @@ in
|
||||
++ optional isMysqlLocal "mysql.service";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
|
||||
path = [ openssl ];
|
||||
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
User = cfg.user;
|
||||
|
||||
Reference in New Issue
Block a user