1
Fork 0

Add basic forgejo config

This commit is contained in:
prescientmoon 2024-05-11 01:09:43 +02:00
parent aadbafcc1e
commit 490a77b67e
Signed by: prescientmoon
SSH key fingerprint: SHA256:UUF9JT2s8Xfyv76b8ZuVL7XrmimH4o49p4b+iexbVH4
13 changed files with 143 additions and 93 deletions
modules/nixos

View file

@ -5,18 +5,33 @@ in
options.satellite.cloudflared = {
tunnel = lib.mkOption {
type = lib.types.string;
description = "Cloudflare tunnel id to use for the `satellite.cloudflared.proxy` helper";
description = "Cloudflare tunnel id to use for the `satellite.cloudflared.targets` helper";
};
proxy = lib.mkOption {
type = lib.types.functionTo lib.types.anything;
description = "Helper function for generating a quick proxy config";
targets = lib.mkOption {
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";
};
host = lib.mkOption {
default = name;
type = lib.types.string;
description = "Host to direct traffic from";
};
};
}));
};
};
config.satellite.cloudflared.proxy = from: {
${cfg.tunnel} = {
ingress.${from} = "http://localhost:8418";
};
};
config.services.cloudflared.tunnels.${cfg.tunnel}.ingress = lib.attrsets.mapAttrs'
(_: { port, host }: {
name = host;
value = "http://localhost:${toString port}";
})
cfg.targets;
}