nix-config/hosts/nixedo/services/vaultwarden.nix

54 lines
1.1 KiB
Nix
Raw Normal View History

2025-04-30 14:21:52 +01:00
{
config,
2025-08-14 16:35:40 +01:00
inputs,
2025-04-30 14:21:52 +01:00
lib,
...
}:
with lib;
let
cfg = homelab.services.${service};
2025-05-03 16:50:27 +01:00
homelab = config.homelab;
2025-04-30 14:21:52 +01:00
service = "vaultwarden";
in
{
2025-05-03 16:50:27 +01:00
options.homelab.services.${service} = {
2025-04-30 14:21:52 +01:00
enable = mkEnableOption "Enable ${service}";
url = mkOption {
2025-05-03 01:13:51 +01:00
default = "${service}.${homelab.domain}";
2025-04-30 14:21:52 +01:00
type = types.str;
};
};
config = mkIf cfg.enable {
services = {
${service} = {
enable = true;
2025-08-14 16:35:40 +01:00
environmentFile = config.age.secrets.vaultwarden-env.path;
2025-04-30 14:21:52 +01:00
config = {
DOMAIN = "https://${cfg.url}";
2025-04-30 20:15:57 +01:00
ROCKET_ADDRESS = "127.0.0.1";
2025-05-03 22:30:39 +01:00
ROCKET_PORT = homelab.ports.${service};
2025-04-30 14:21:52 +01:00
SIGNUPS_ALLOWED = false;
};
};
2025-08-14 16:35:40 +01:00
nginx.virtualHosts.${cfg.url} = {
forceSSL = true;
useACMEHost = homelab.domain;
locations."/" = {
proxyPass = "http://localhost:${toString config.services.${service}.config.ROCKET_PORT}";
recommendedProxySettings = true;
};
2025-04-30 14:21:52 +01:00
};
};
2025-08-14 16:35:40 +01:00
age.secrets.vaultwarden-env.file = "${inputs.self}/secrets/vaultwarden-env.age";
2025-04-30 14:21:52 +01:00
};
}