fruitbasket/modules/vaultwarden.nix

44 lines
1.1 KiB
Nix
Raw Normal View History

2023-07-04 14:20:55 +02:00
{ config, ... }:
let
domain = "vault.${config.fsr.domain}";
in
{
sops.secrets."vaultwarden_env".owner = "vaultwarden";
services.vaultwarden = {
enable = true;
dbBackend = "postgresql";
environmentFile = config.sops.secrets."vaultwarden_env".path;
config = {
domain = "https://${domain}";
signupsAllowed = false;
# somehow this works
databaseUrl = "postgresql://vaultwarden@%2Frun%2Fpostgresql/vaultwarden";
rocketPort = 8000;
2023-07-12 15:46:25 +02:00
smtpHost = "127.0.0.1";
smtpPort = 25;
smtpSSL = false;
smtpFrom = "noreply@${config.fsr.domain}";
smtpFromName = "iFSR Vaultwarden";
2023-07-04 14:20:55 +02:00
};
};
services.postgresql = {
enable = true;
ensureUsers = [
{
name = "vaultwarden";
ensurePermissions = {
"DATABASE vaultwarden" = "ALL PRIVILEGES";
};
}
];
ensureDatabases = [ "vaultwarden" ];
};
services.nginx.virtualHosts."${domain}" = {
enableACME = true;
forceSSL = true;
locations."/" = {
proxyPass = "http://127.0.0.1:${toString config.services.vaultwarden.config.rocketPort}";
};
};
}