1
Fork 0
satellite/modules/nixos/cloudflared.nix

38 lines
1,009 B
Nix
Raw Normal View History

2024-05-09 15:20:03 +02:00
{ config, lib, ... }:
let cfg = config.satellite.cloudflared;
in
{
options.satellite.cloudflared = {
tunnel = lib.mkOption {
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;
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
}