2023-05-19 11:42:43 +02:00
|
|
|
{ config, ... }:
|
2023-01-25 13:48:58 +01:00
|
|
|
let
|
2023-09-19 13:47:08 +02:00
|
|
|
domain = "vault.${config.networking.domain}";
|
2023-01-25 13:48:58 +01:00
|
|
|
in
|
|
|
|
{
|
2023-01-25 14:24:10 +01:00
|
|
|
sops.secrets."vaultwarden/env".owner = "vaultwarden";
|
2023-01-25 13:48:58 +01:00
|
|
|
services.vaultwarden = {
|
|
|
|
enable = true;
|
|
|
|
dbBackend = "postgresql";
|
|
|
|
environmentFile = config.sops.secrets."vaultwarden/env".path;
|
|
|
|
config = {
|
2023-01-25 14:24:10 +01:00
|
|
|
domain = "https://${domain}";
|
2023-01-25 13:48:58 +01:00
|
|
|
signupsAllowed = false;
|
2023-01-25 14:24:10 +01:00
|
|
|
# somehow this works
|
|
|
|
databaseUrl = "postgresql://vaultwarden@%2Frun%2Fpostgresql/vaultwarden";
|
2023-01-25 13:48:58 +01:00
|
|
|
rocketPort = 8000;
|
|
|
|
};
|
2023-01-25 14:24:10 +01: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}";
|
2023-01-25 13:48:58 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|