nixos-config/hosts/nuc/modules/vaultwarden/default.nix

39 lines
964 B
Nix
Raw Normal View History

2023-01-25 13:48:58 +01:00
{ config, pkgs, ... }:
let
domain = "vault.rfive.de";
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
};
};
}