Set up forgejo ssh
This commit is contained in:
parent
861f2e81e2
commit
a94ba0499d
4 changed files with 75 additions and 43 deletions
modules/nixos
|
@ -1,5 +1,6 @@
|
|||
{ config, lib, ... }:
|
||||
let cfg = config.satellite.cloudflared;
|
||||
let
|
||||
cfg = config.satellite.cloudflared;
|
||||
in
|
||||
{
|
||||
options.satellite.cloudflared = {
|
||||
|
@ -17,52 +18,74 @@ in
|
|||
at = lib.mkOption {
|
||||
description = "List of hosts to set up ingress rules for";
|
||||
default = { };
|
||||
type = lib.types.attrsOf (lib.types.submodule ({ name, config, ... }: {
|
||||
options = {
|
||||
subdomain = lib.mkOption {
|
||||
description = ''
|
||||
Subdomain to use for host generation.
|
||||
Only required if `host` is not set manually.
|
||||
'';
|
||||
type = lib.types.str;
|
||||
default = name;
|
||||
};
|
||||
type = lib.types.attrsOf (
|
||||
lib.types.submodule (
|
||||
{ name, config, ... }:
|
||||
{
|
||||
options = {
|
||||
subdomain = lib.mkOption {
|
||||
description = ''
|
||||
Subdomain to use for host generation.
|
||||
Only required if `host` is not set manually.
|
||||
'';
|
||||
type = lib.types.str;
|
||||
default = name;
|
||||
};
|
||||
|
||||
port = lib.mkOption {
|
||||
description = "Localhost port to point the tunnel at";
|
||||
type = lib.types.port;
|
||||
};
|
||||
port = lib.mkOption {
|
||||
description = "Localhost port to point the tunnel at";
|
||||
type = lib.types.port;
|
||||
};
|
||||
|
||||
host = lib.mkOption {
|
||||
description = "Host to direct traffic from";
|
||||
type = lib.types.str;
|
||||
default = "${config.subdomain}.${cfg.domain}";
|
||||
};
|
||||
host = lib.mkOption {
|
||||
description = "Host to direct traffic from";
|
||||
type = lib.types.str;
|
||||
default = "${config.subdomain}.${cfg.domain}";
|
||||
};
|
||||
|
||||
url = lib.mkOption {
|
||||
description = "External https url used to access this host";
|
||||
type = lib.types.str;
|
||||
};
|
||||
};
|
||||
protocol = lib.mkOption {
|
||||
description = "The protocol to redirect traffic through";
|
||||
type = lib.types.str;
|
||||
default = "http";
|
||||
};
|
||||
|
||||
config.url = "https://${config.host}";
|
||||
}));
|
||||
url = lib.mkOption {
|
||||
description = "External https url used to access this host";
|
||||
type = lib.types.str;
|
||||
};
|
||||
};
|
||||
|
||||
config.url = "https://${config.host}";
|
||||
}
|
||||
)
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
config.services.cloudflared.tunnels.${cfg.tunnel}.ingress = lib.attrsets.mapAttrs'
|
||||
(_: { port, host, ... }: {
|
||||
config.services.cloudflared.tunnels.${cfg.tunnel}.ingress = lib.attrsets.mapAttrs' (
|
||||
_:
|
||||
{
|
||||
port,
|
||||
host,
|
||||
protocol,
|
||||
...
|
||||
}:
|
||||
{
|
||||
name = host;
|
||||
value = "http://localhost:${toString port}";
|
||||
})
|
||||
cfg.at;
|
||||
value = "${protocol}://localhost:${toString port}";
|
||||
}
|
||||
) cfg.at;
|
||||
|
||||
config.satellite.dns.records =
|
||||
let mkDnsRecord = { subdomain, ... }: {
|
||||
type = "CNAME";
|
||||
at = subdomain;
|
||||
zone = cfg.domain;
|
||||
value = "${cfg.tunnel}.cfargotunnel.com.";
|
||||
};
|
||||
in lib.attrsets.mapAttrsToList (_: mkDnsRecord) cfg.at;
|
||||
let
|
||||
mkDnsRecord =
|
||||
{ subdomain, ... }:
|
||||
{
|
||||
type = "CNAME";
|
||||
at = subdomain;
|
||||
zone = cfg.domain;
|
||||
value = "${cfg.tunnel}.cfargotunnel.com.";
|
||||
};
|
||||
in
|
||||
lib.attrsets.mapAttrsToList (_: mkDnsRecord) cfg.at;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue