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

42 lines
1 KiB
Nix
Raw Normal View History

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-11-16 14:40:40 +01:00
age.secrets.vaultwarden = {
file = ../../../../secrets/nuc/vaultwarden.age;
owner = "vaultwarden";
};
2023-01-25 13:48:58 +01:00
services.vaultwarden = {
enable = true;
dbBackend = "postgresql";
2023-11-16 14:40:40 +01:00
environmentFile = config.age.secrets.vaultwarden.path;
2023-01-25 13:48:58 +01:00
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
};
};
}