diff --git a/hosts/nixedo/homelab.nix b/hosts/nixedo/homelab.nix index 3c4095e4..617aa091 100644 --- a/hosts/nixedo/homelab.nix +++ b/hosts/nixedo/homelab.nix @@ -23,6 +23,8 @@ jellyfin.enable = true; paperless.enable = true; uptime-kuma.enable = true; + + vaultwarden.enable = true; }; }; } diff --git a/hosts/nixedo/modules/acme.nix b/hosts/nixedo/modules/acme.nix index a21f9720..f6941b4e 100644 --- a/hosts/nixedo/modules/acme.nix +++ b/hosts/nixedo/modules/acme.nix @@ -33,6 +33,7 @@ "talking-drupal-tailwindcss.oliverdavies.uk" "tome.oliverdavies.uk" "uptime.oliverdavies.uk" + "vaultwarden.oliverdavies.uk" "wp-tailwind.oliverdavies.uk" "www.oliverdavies.uk" "zet.oliverdavies.uk" diff --git a/hosts/nixedo/services/default.nix b/hosts/nixedo/services/default.nix index 1921dcd2..5b65a247 100644 --- a/hosts/nixedo/services/default.nix +++ b/hosts/nixedo/services/default.nix @@ -3,5 +3,6 @@ ./homepage ./samba.nix ./uptime-kuma.nix + ./vaultwarden.nix ]; } diff --git a/hosts/nixedo/services/vaultwarden.nix b/hosts/nixedo/services/vaultwarden.nix new file mode 100644 index 00000000..0402699f --- /dev/null +++ b/hosts/nixedo/services/vaultwarden.nix @@ -0,0 +1,68 @@ +{ + config, + lib, + options, + ... +}: + +with lib; + +let + cfg = homelab.services.${service}; + homelab = config.features.homelab; + service = "vaultwarden"; +in +{ + options.features.homelab.services.${service} = { + enable = mkEnableOption "Enable ${service}"; + + url = mkOption { + default = "${service}.${homelab.baseDomain}"; + type = types.str; + }; + + homepage.name = mkOption { + default = "Vaultwarden"; + type = types.str; + }; + + homepage.description = mkOption { + default = "Unofficial Bitwarden compatible server written in Rust"; + type = types.str; + }; + + homepage.icon = mkOption { + default = "bitwarden"; + type = types.str; + }; + + homepage.category = mkOption { + default = "Services"; + type = types.str; + }; + }; + + config = mkIf cfg.enable { + services = { + ${service} = { + enable = true; + + config = { + DOMAIN = "https://${cfg.url}"; + ROCKET_PORT = 8222; + SIGNUPS_ALLOWED = false; + }; + }; + + nginx.virtualHosts.${cfg.url} = { + forceSSL = true; + useACMEHost = homelab.baseDomain; + + locations."/" = { + proxyPass = "http://localhost:${toString config.services.${service}.config.ROCKET_PORT}"; + recommendedProxySettings = true; + }; + }; + }; + }; +}