2023-06-07 20:23:49 +02:00
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
let
|
|
|
|
cfg = config.services.vaultwarden;
|
|
|
|
domain = "pw.feal.no";
|
2024-05-26 11:05:26 +02:00
|
|
|
address = "127.0.1.2";
|
|
|
|
port = 3011;
|
|
|
|
wsPort = 3012;
|
2023-06-07 20:23:49 +02:00
|
|
|
in {
|
|
|
|
sops.secrets."vaultwarden/admintoken" = {
|
|
|
|
owner = "vaultwarden";
|
|
|
|
group = "vaultwarden";
|
|
|
|
};
|
|
|
|
|
|
|
|
services.vaultwarden = {
|
|
|
|
enable = true;
|
|
|
|
dbBackend = "postgresql";
|
|
|
|
environmentFile = config.sops.secrets."vaultwarden/admintoken".path;
|
|
|
|
config = {
|
|
|
|
domain = "https://${domain}";
|
|
|
|
|
|
|
|
rocketAddress = address;
|
|
|
|
rocketPort = port;
|
2024-05-26 11:05:26 +02:00
|
|
|
|
2023-06-07 20:23:49 +02:00
|
|
|
websocketEnabled = true;
|
2024-05-26 11:05:26 +02:00
|
|
|
websocketAddress = address;
|
|
|
|
websocketPort = wsPort;
|
2023-06-07 20:23:49 +02:00
|
|
|
|
2024-05-26 11:05:26 +02:00
|
|
|
signupsAllowed = true;
|
|
|
|
signupsVerify = true;
|
|
|
|
signupsDomainsWhitelist = "albrigtsen.it";
|
|
|
|
|
|
|
|
databaseUrl = "postgresql://vaultwarden@/vaultwarden";
|
2023-06-07 20:23:49 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-12-26 11:45:12 +01:00
|
|
|
services.postgresql = {
|
|
|
|
ensureDatabases = [ "vaultwarden" ];
|
|
|
|
ensureUsers = [{
|
|
|
|
name = "vaultwarden";
|
|
|
|
ensureDBOwnership = true;
|
|
|
|
}];
|
|
|
|
};
|
2023-06-07 20:23:49 +02:00
|
|
|
|
2024-03-07 23:45:25 +01:00
|
|
|
services.postgresqlBackup.databases = [ "vaultwarden" ];
|
|
|
|
|
2023-06-07 20:23:49 +02:00
|
|
|
services.nginx.virtualHosts."${domain}" = {
|
2023-12-26 11:45:12 +01:00
|
|
|
forceSSL = true;
|
|
|
|
enableACME = true;
|
|
|
|
|
|
|
|
listen = [
|
|
|
|
{ addr = "192.168.10.175"; port = 43443; ssl = true; }
|
|
|
|
{ addr = "192.168.10.175"; port = 43080; ssl = false; }
|
|
|
|
];
|
|
|
|
|
2023-06-07 20:23:49 +02:00
|
|
|
extraConfig = ''
|
|
|
|
client_max_body_size 128M;
|
|
|
|
'';
|
|
|
|
locations."/" = {
|
|
|
|
proxyPass = "http://${address}:${toString port}";
|
|
|
|
proxyWebsockets = true;
|
|
|
|
};
|
|
|
|
locations."/notifications/hub" = {
|
2024-05-26 11:05:26 +02:00
|
|
|
proxyPass = "http://${address}:${toString wsPort}";
|
2023-06-07 20:23:49 +02:00
|
|
|
proxyWebsockets = true;
|
|
|
|
};
|
|
|
|
locations."/notifications/hub/negotiate" = {
|
|
|
|
proxyPass = "http://${address}:${toString port}";
|
|
|
|
proxyWebsockets = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|