depot/cluster/services/websites/default.nix

58 lines
1.3 KiB
Nix
Raw Normal View History

2023-08-31 01:55:45 +03:00
{ depot, lib, ... }:
let
2023-08-31 01:55:45 +03:00
inherit (depot.lib.meta) domain;
acmeUseDNS = name: conf: {
name = conf.useACMEHost or conf.serverName or name;
value = {
dnsProvider = "pdns";
webroot = null;
};
};
isACME = _: conf: conf ? enableACME && conf.enableACME;
in
2022-08-09 21:10:25 +03:00
{
services.websites = {
nodes.host = [ "checkmate" "thunderskin" "VEGAS" "prophet" ];
2023-08-31 01:55:45 +03:00
nixos.host = { config, depot, ... }: let
importWebsites = expr: import expr {
tools = depot.lib.nginx;
inherit (depot) packages;
};
websites = depot.lib.nginx.mappers.mapSubdomains (importWebsites ./websites.nix);
in {
services.nginx.virtualHosts = websites;
security.acme.certs = lib.mapAttrs' acmeUseDNS (lib.filterAttrs isACME websites);
consul.services.nginx = {
mode = "external";
definition = {
name = "static-lb";
address = depot.reflection.interfaces.primary.addrPublic;
port = 443;
checks = lib.singleton {
interval = "60s";
tcp = "127.0.0.1:80";
};
};
};
2022-08-09 21:10:25 +03:00
};
};
monitoring.blackbox.targets = {
web = {
address = "https://www.${domain}";
module = "https2xx";
2022-08-09 21:10:25 +03:00
};
};
dns.records = lib.genAttrs [ "www" "draw" "stop-using-nix-env" "whoami" ] (lib.const {
consulService = "static-lb";
});
2022-08-09 21:10:25 +03:00
}