From 5c4740989e1dcf1772eae3315b3ef348d7aa078b Mon Sep 17 00:00:00 2001 From: Jakob Lechner Date: Wed, 22 Nov 2023 14:49:27 +0000 Subject: [PATCH] Add pretix extraDomains --- .../weinturm-pretix-prod/services/pretix.nix | 4 ++ pkgs/pretix/module.nix | 38 ++++++++++++------- 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/hosts/weinturm-pretix-prod/services/pretix.nix b/hosts/weinturm-pretix-prod/services/pretix.nix index 72ef2df..2afab88 100644 --- a/hosts/weinturm-pretix-prod/services/pretix.nix +++ b/hosts/weinturm-pretix-prod/services/pretix.nix @@ -4,6 +4,10 @@ enable = true; instanceName = "Weinturm Open Air"; domain = "tickets.weinturm-open-air.de"; + extraDomains = [ + "tickets.wasted-openair.de" + "oel.wasted-openair.de" + ]; enableTls = true; enableRegistration = false; passwordReset = true; diff --git a/pkgs/pretix/module.nix b/pkgs/pretix/module.nix index 12872bb..7705e0a 100644 --- a/pkgs/pretix/module.nix +++ b/pkgs/pretix/module.nix @@ -66,7 +66,7 @@ let }; in { - options.services.pretix = with lib; { + options.services.pretix = with lib; with lib.types; { enable = mkEnableOption "Enable pretix ticket shop application"; instanceName = mkOption { type = types.str; @@ -74,7 +74,13 @@ in }; domain = mkOption { type = types.str; - description = "The installation’s domain"; + description = "The installation’s main domain"; + example = "pretix.example.net"; + }; + extraDomains = mkOption { + type = listOf str; + description = "A list of extra domains"; + default = [ ]; }; enableTls = mkEnableOption "Whether to use TLS or not"; enableRegistration = mkEnableOption "Enables or disables the registration of new admin users."; @@ -124,17 +130,23 @@ in recommendedOptimisation = true; recommendedProxySettings = true; recommendedTlsSettings = true; - virtualHosts."${cfg.domain}" = { - enableACME = cfg.enableTls; - forceSSL = cfg.enableTls; - kTLS = cfg.enableTls; - locations."/" = { - proxyPass = "http://${bind.host}:${toString bind.port}"; - }; - extraConfig = '' - ${hstsHeader} - ''; - }; + virtualHosts = lib.listToAttrs (map + (d: { + name = d; + value = { + enableACME = cfg.enableTls; + forceSSL = cfg.enableTls; + kTLS = cfg.enableTls; + locations."/" = { + proxyPass = "http://${bind.host}:${toString bind.port}"; + }; + extraConfig = '' + ${hstsHeader} + ''; + }; + }) + ([ cfg.domain ] ++ cfg.extraDomains) + ); }; services.postgresql = {