infrastructure/machines/web01/metis/default.nix
Tom Hubrecht 0e3463102c
All checks were successful
build configuration / build_and_cache_geo02 (push) Successful in 1m12s
build configuration / build_and_cache_storage01 (push) Successful in 1m21s
build configuration / build_and_cache_rescue01 (push) Successful in 1m21s
build configuration / build_and_cache_geo01 (push) Successful in 1m24s
build configuration / build_and_cache_compute01 (push) Successful in 1m40s
build configuration / build_and_cache_vault01 (push) Successful in 1m29s
build configuration / build_and_cache_web03 (push) Successful in 1m21s
build configuration / build_and_cache_bridge01 (push) Successful in 1m8s
build configuration / build_and_cache_web02 (push) Successful in 1m30s
lint / check (push) Successful in 23s
build configuration / build_and_cache_web01 (push) Successful in 2m34s
feat(metis): Update and validate providers
2024-10-24 00:27:15 +02:00

40 lines
1 KiB
Nix

{
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;
}