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";
|
2023-11-24 09:57:15 +01:00
|
|
|
ensureDBOwnership = true;
|
2023-01-25 14:24:10 +01:00
|
|
|
}
|
|
|
|
];
|
|
|
|
ensureDatabases = [ "vaultwarden" ];
|
|
|
|
};
|
2024-05-21 18:44:04 +02:00
|
|
|
services.caddy.virtualHosts."${domain}".extraConfig = ''
|
|
|
|
reverse_proxy 127.0.0.1:${toString config.services.vaultwarden.config.rocketPort}
|
|
|
|
'';
|
2023-01-25 13:48:58 +01:00
|
|
|
}
|