Files
nix/modules/core/infra/cloudflared.nix
T
2026-08-22 03:36:34 -05:00

35 lines
989 B
Nix

let
uuid = "d4c4a385-05c7-4dff-b6f1-9bd02693a80a";
domain = "bug.tools";
creds = "/home/bug/.cloudflared/${uuid}.json";
in {
den.aspects.cloudflared = {
nixos = { config, pkgs, lib, ... }: {
options.den.tunnels = lib.mkOption {
default = [];
description = "cloudflared tunnels";
type = lib.types.listOf lib.types.str;
};
config = {
environment.systemPackages = [ pkgs.cloudflared ];
environment.etc."cloudflared/${uuid}.json".source = creds;
services.cloudflared = {
enable = true;
tunnels.${uuid} = {
credentialsFile = "/etc/cloudflared/${uuid}.json";
default = "http_status:404";
ingress = lib.listToAttrs (map (subdomain: {
name = "${subdomain}.${domain}";
value = "http://127.0.0.1:${toString config.den.portmap.${subdomain}}";
}) config.den.tunnels);
};
};
};
};
};
}