{ lib, pkgs, sources, ... }: let inherit (lib) mapAttrsToList match; metis = import sources.metis { inherit pkgs; }; in { services.nginx.virtualHosts."calendrier.dgnum.eu" = { enableACME = true; forceSSL = true; root = metis.package; locations = lib.mapAttrs' ( name: domain: lib.nameValuePair "/cal/${name}/" { extraConfig = '' proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Server $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass https://${domain}/remote.php/dav/public-calendars/; ''; } ) metis.providers; extraConfig = '' rewrite ^/calendrier(.*)$ $1 permanent; ''; }; assertions = mapAttrsToList (name: domain: { assertion = (match "[a-z-]+" name == [ ]) && (match "[a-z.-]+" domain == [ ]); message = "The provider `${name}` associated to the domain `${domain}` seems to have an incorrect definition."; }) metis.providers; }