2023-07-04 14:20:55 +02:00
|
|
|
{ config, ... }:
|
|
|
|
let
|
2023-09-17 20:10:55 +02:00
|
|
|
domain = "vault.${config.networking.domain}";
|
2023-07-04 14:20:55 +02:00
|
|
|
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;
|
|
|
|
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;
|
2023-09-17 20:10:55 +02:00
|
|
|
smtpFrom = "noreply@${config.networking.domain}";
|
2023-07-12 15:46:25 +02:00
|
|
|
smtpFromName = "iFSR Vaultwarden";
|
2023-07-04 14:20:55 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
services.postgresql = {
|
|
|
|
enable = true;
|
|
|
|
ensureUsers = [
|
|
|
|
{
|
|
|
|
name = "vaultwarden";
|
2023-12-14 15:42:10 +01:00
|
|
|
ensureDBOwnership = true;
|
2023-07-04 14:20:55 +02:00
|
|
|
}
|
|
|
|
];
|
|
|
|
ensureDatabases = [ "vaultwarden" ];
|
|
|
|
};
|
|
|
|
services.nginx.virtualHosts."${domain}" = {
|
|
|
|
enableACME = true;
|
|
|
|
forceSSL = true;
|
|
|
|
locations."/" = {
|
|
|
|
proxyPass = "http://127.0.0.1:${toString config.services.vaultwarden.config.rocketPort}";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|