diff --git a/dafoe/services/default.nix b/dafoe/services/default.nix index f1e0166..ed9b731 100644 --- a/dafoe/services/default.nix +++ b/dafoe/services/default.nix @@ -5,10 +5,11 @@ ./ddns.nix ./nginx.nix ./forgejo.nix - #./printing.nix ./restic.nix ./ssh.nix ./vaultwarden.nix ./nextcloud.nix + ./domains.nix ]; + services.domains.enable = true; } diff --git a/dafoe/services/domains.nix b/dafoe/services/domains.nix new file mode 100644 index 0000000..c9c143a --- /dev/null +++ b/dafoe/services/domains.nix @@ -0,0 +1,64 @@ +{ config, lib, pkgs, ... }: +with lib; +let + cfg = config.domains; +in + { + domains = { + enable = mkOption { + default = false; + type = types.nullOr types.bool; + }; + domain = mkOption { + description = '' + Domain of the server. + ''; + type = types.nullOr types.str; + }; + git = mkOption { + description = '' + Subdomain of the git instance. + ''; + type = types.nullOr types.str; + default = "git"; + }; + vaultwarden = mkOption { + description = '' + Subdomain of the vaultwarden instance + ''; + default = "vaultwarden"; + type = types.nullOr types.str; + }; + video = mkOption { + description = '' + Subdomain of the video instance + ''; + default = "video"; + type = types.nullOr types.str; + }; + www = mkOption { + description = '' + Subdomain of the www instance + ''; + default = "www"; + type = types.nullOr types.str; + }; + files = mkOption { + description = '' + Subdomain of the files instance + ''; + default = "files"; + type = types.nullOr types.str; + }; + cloud = mkOption { + description = '' + Subdomain of the cloud instance + ''; + default = "cloud"; + type = types.nullOr types.str; + }; + }; + config = mkIf cfg.enable { + gitURL = "${cfg.git}.${cfg.domain}"; + }; + } \ No newline at end of file diff --git a/dafoe/services/nextcloud.nix b/dafoe/services/nextcloud.nix index 483eec1..d9b62f4 100644 --- a/dafoe/services/nextcloud.nix +++ b/dafoe/services/nextcloud.nix @@ -9,7 +9,6 @@ config.adminpassFile = "${../../nix-secrets/dafoe/nextcloud/adminpass}"; configureRedis = true; maxUploadSize = "1G"; - #nginx.enable = true; settings.overwriteProtocol = "https"; }; } diff --git a/dafoe/services/nginx.nix b/dafoe/services/nginx.nix index 45c2da5..3783f9a 100644 --- a/dafoe/services/nginx.nix +++ b/dafoe/services/nginx.nix @@ -1,4 +1,4 @@ -{ lib, pkgs, inputs, ... }: +{ lib, pkgs, inputs, config, ... }: { services.nginx = { enable = true; @@ -8,50 +8,46 @@ recommendedTlsSettings = true; }; - services.nginx.virtualHosts = let tld = "vatthauer.xyz"; in + services.nginx.virtualHosts = let domain = "vatthauer.xyz"; in { - "git.${tld}" = { + "config.domains.gitURL" = { enableACME = true; forceSSL = true; locations."/" = { proxyPass = "http://localhost:3001/"; }; }; - }; - - services.nginx.virtualHosts."vaultwarden.vatthauer.xyz" = { - enableACME = true; - forceSSL = true; - locations."/" = { - proxyPass = "http://localhost:8222/"; + "vaultwarden.${domain}" = { + enableACME = true; + forceSSL = true; + locations."/" = { + proxyPass = "http://localhost:8222/"; + }; }; - }; - - services.nginx.virtualHosts."video.vatthauer.xyz" = { - enableACME = true; - forceSSL = false; - locations."/" = { - proxyPass = "http://localhost:8096"; + "video.${domain}" = { + enableACME = true; + forceSSL = false; + locations."/" = { + proxyPass = "http://localhost:8096"; + }; }; - }; - services.nginx.virtualHosts."www.vatthauer.xyz" = { - serverAliases = [ "vatthauer.xyz" ]; - forceSSL = true; - enableACME = true; - root = pkgs.callPackage ./resumee-website.nix {}; - }; - services.nginx.virtualHosts."files.vatthauer.xyz" = { - forceSSL = true; - enableACME = true; - locations."/" = { - root = "/var/www"; - extraConfig = "autoindex on;"; + "www.${domain}" = { + serverAliases = [ domain ]; + forceSSL = true; + enableACME = true; + root = pkgs.callPackage ./resumee-website.nix {}; + }; + "files.${domain}" = { + forceSSL = true; + enableACME = true; + locations."/" = { + root = "/var/www"; + extraConfig = "autoindex on;"; + }; + }; + "cloud.${domain}" = { + forceSSL = true; + enableACME = true; }; - }; - services.nginx.virtualHosts."cloud.vatthauer.xyz" = { - forceSSL = true; - enableACME = true; - #locations."/".proxyPass = "http://localhost:8080"; - # nextcloud does location setup itself }; } diff --git a/dafoe/services/printing.nix b/dafoe/services/printing.nix deleted file mode 100644 index 321e5b2..0000000 --- a/dafoe/services/printing.nix +++ /dev/null @@ -1,20 +0,0 @@ -{ pkgs, ... }: -{ - # Enable CUPS to print documents. - services.avahi = { - enable = true; - publish.enable = true; - publish.userServices = true; - }; - services.printing = { - enable = true; - drivers = [ pkgs.splix ]; - browsing = true; - listenAddresses = [ "*:631" ]; - allowFrom = [ "all" ]; - defaultShared = true; - extraConf = '' - BrowseLocalProtocols all - ''; - }; -}