diff --git a/nixos/modules/services/web-apps/writefreely.nix b/nixos/modules/services/web-apps/writefreely.nix index 3a0f66185ea1..fe7b9ef6f00b 100644 --- a/nixos/modules/services/web-apps/writefreely.nix +++ b/nixos/modules/services/web-apps/writefreely.nix @@ -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;