new site-config.nix holds values previously duplicated across hosts:
domain, old_domain, contact_email, timezone, binary_cache (url + pubkey),
dns_servers, lan (cidr + gateway), hosts.{muffin,yarn} (ip/alias/ssh_host_key),
ssh_keys.{laptop,desktop,ci_deploy}.
threaded through specialArgs on all three hosts + home-manager extraSpecialArgs +
homeConfigurations.primary + serverLib. service-configs.nix now takes
{ site_config } as a function arg and drops its https namespace; per-service
domains (gitea/matrix/ntfy/mollysocket/livekit/firefox-sync/grafana) are
derived from site_config.domain. ~15 service files and 6 vm tests migrated.
breakage fixes rolled in:
- home/progs/zen/dark-reader.nix: 5 stale *.gardling.com entries in
disabledFor rewritten to *.sigkill.computer (caddy 301s the old names so
these never fired and the new sigkill urls were getting dark-reader applied)
- modules/desktop-common.nix: drop unused hugepagesz=1G/hugepages=3
kernelParams (no consumer on mreow or yarn; xmrig on muffin still reserves
its own via services/monero/xmrig.nix)
verification: muffin toplevel is bit-identical to pre-refactor baseline.
mreow/yarn toplevels differ only in boot.json kernelParams + darkreader
storage.js (nix-diff verified). deployGuardTest and fail2banVaultwardenTest
(latter exercises site_config.domain via bitwarden.nix) pass.
47 lines
1.1 KiB
Nix
47 lines
1.1 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
site_config,
|
|
service_configs,
|
|
...
|
|
}:
|
|
{
|
|
imports = [
|
|
(lib.serviceMountWithZpool "vaultwarden" service_configs.zpool_ssds [
|
|
service_configs.vaultwarden.path
|
|
])
|
|
(lib.serviceFilePerms "vaultwarden" [
|
|
"Z ${service_configs.vaultwarden.path} 0700 vaultwarden vaultwarden"
|
|
])
|
|
(lib.mkFail2banJail {
|
|
name = "vaultwarden";
|
|
failregex = ''^.*Username or password is incorrect\. Try again\. IP: <HOST>\..*$'';
|
|
})
|
|
];
|
|
|
|
services.vaultwarden = {
|
|
enable = true;
|
|
dbBackend = "postgresql";
|
|
configurePostgres = true;
|
|
config = {
|
|
# Refer to https://github.com/dani-garcia/vaultwarden/blob/main/.env.template
|
|
DOMAIN = "https://bitwarden.${site_config.domain}";
|
|
SIGNUPS_ALLOWED = false;
|
|
|
|
ROCKET_ADDRESS = "127.0.0.1";
|
|
ROCKET_PORT = service_configs.ports.private.vaultwarden.port;
|
|
ROCKET_LOG = "critical";
|
|
};
|
|
};
|
|
|
|
services.caddy.virtualHosts."bitwarden.${site_config.domain}".extraConfig = ''
|
|
encode zstd gzip
|
|
|
|
reverse_proxy :${toString config.services.vaultwarden.config.ROCKET_PORT} {
|
|
header_up X-Real-IP {remote_host}
|
|
}
|
|
'';
|
|
|
|
}
|