diff --git a/machines/storage01/garage.nix b/machines/storage01/garage.nix index e4d0fcd..dd3b6b9 100644 --- a/machines/storage01/garage.nix +++ b/machines/storage01/garage.nix @@ -1,9 +1,4 @@ -{ - config, - pkgs, - lib, - ... -}: +{ config, pkgs, ... }: let host = "s3.dgnum.eu"; @@ -12,16 +7,17 @@ let data_dir = "/data/slow/garage/data"; metadata_dir = "/data/fast/garage/meta"; - buckets = { - "castopod-dgnum" = { }; - "peertube-videos-dgnum" = { }; - "boussole-sante.normalesup.eu" = { - mainDomain = true; - }; - "simi.normalesup.eu" = { - mainDomain = true; - }; - }; + domains = [ + "boussole-sante.normalesup.eu" + "simi.normalesup.eu" + ]; + + buckets = [ + "castopod-dgnum" + "peertube-videos-dgnum" + ] ++ domains; + + mkHosted = host: builtins.map (b: "${b}.${host}"); in { services.garage = { @@ -79,7 +75,7 @@ in enableACME = true; forceSSL = true; - serverAliases = builtins.map (b: "${b}.${host}") (builtins.attrNames buckets); + serverAliases = mkHosted host buckets; locations."/".extraConfig = '' proxy_pass http://127.0.0.1:3900; @@ -95,16 +91,13 @@ in enableACME = true; forceSSL = true; - serverAliases = lib.flatten ( - lib.mapAttrsToList ( - b: v: lib.singleton "${b}.${webHost}" ++ lib.optional (v ? mainDomain && v.mainDomain) b - ) buckets - ); + serverAliases = domains ++ (mkHosted webHost buckets); locations."/".extraConfig = '' proxy_pass http://127.0.0.1:3902; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header Host $host;''; + proxy_set_header Host $host; + ''; }; }; }