2024-05-09 15:20:03 +02:00
|
|
|
{ config, lib, ... }:
|
|
|
|
let cfg = config.satellite.cloudflared;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options.satellite.cloudflared = {
|
|
|
|
tunnel = lib.mkOption {
|
2024-05-21 01:56:53 +02:00
|
|
|
type = lib.types.str;
|
2024-07-06 19:32:14 +02:00
|
|
|
description = "Cloudflare tunnel id to use for the `satellite.cloudflared.at` helper";
|
2024-05-09 15:20:03 +02:00
|
|
|
};
|
|
|
|
|
2024-07-06 19:32:14 +02:00
|
|
|
at = lib.mkOption {
|
2024-05-11 01:09:43 +02:00
|
|
|
description = "List of hosts to set up ingress rules for";
|
|
|
|
default = { };
|
|
|
|
type = lib.types.attrsOf (lib.types.submodule ({ name, ... }: {
|
|
|
|
options = {
|
|
|
|
port = lib.mkOption {
|
|
|
|
type = lib.types.port;
|
|
|
|
description = "Localhost port to point the tunnel at";
|
|
|
|
};
|
2024-05-09 15:20:03 +02:00
|
|
|
|
2024-05-11 01:09:43 +02:00
|
|
|
host = lib.mkOption {
|
|
|
|
default = name;
|
2024-05-21 01:56:53 +02:00
|
|
|
type = lib.types.str;
|
2024-05-11 01:09:43 +02:00
|
|
|
description = "Host to direct traffic from";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}));
|
2024-05-09 15:20:03 +02:00
|
|
|
};
|
|
|
|
};
|
2024-05-11 01:09:43 +02:00
|
|
|
|
|
|
|
config.services.cloudflared.tunnels.${cfg.tunnel}.ingress = lib.attrsets.mapAttrs'
|
|
|
|
(_: { port, host }: {
|
|
|
|
name = host;
|
|
|
|
value = "http://localhost:${toString port}";
|
|
|
|
})
|
2024-07-06 19:32:14 +02:00
|
|
|
cfg.at;
|
2024-05-09 15:20:03 +02:00
|
|
|
}
|