mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-01-21 12:51:34 +01:00
Add custom libs subdomainOf and rootDomainOf
This commit is contained in:
parent
f3ea2b75e6
commit
8807d38b57
3 changed files with 9 additions and 10 deletions
|
|
@ -1,3 +1,7 @@
|
|||
lib: {
|
||||
isTailscaleDomain = domain: domain |> lib.hasSuffix ".ts.net";
|
||||
|
||||
subdomainOf = domain: domain |> lib.splitString "." |> lib.head;
|
||||
|
||||
rootDomainOf = domain: domain |> lib.splitString "." |> lib.tail |> lib.concatStringsSep ".";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,9 +20,6 @@ let
|
|||
443
|
||||
];
|
||||
|
||||
subdomainOf = domain: domain |> lib.splitString "." |> lib.head;
|
||||
rootDomainOf = domain: domain |> lib.splitString "." |> lib.tail |> lib.concatStringsSep ".";
|
||||
|
||||
mkWildCardDomain =
|
||||
rootDomain: values:
|
||||
lib.nameValuePair "*.${rootDomain}" {
|
||||
|
|
@ -33,8 +30,8 @@ let
|
|||
{ domain, port, ... }:
|
||||
''
|
||||
import subdomain-log ${domain}
|
||||
@${subdomainOf domain} host ${domain}
|
||||
handle @${subdomainOf domain} {
|
||||
@${lib.custom.subdomainOf domain} host ${domain}
|
||||
handle @${lib.custom.subdomainOf domain} {
|
||||
reverse_proxy localhost:${toString port}
|
||||
}
|
||||
'';
|
||||
|
|
@ -47,7 +44,7 @@ let
|
|||
lib.nameValuePair domain {
|
||||
logFormat = "output file ${config.services.caddy.logDir}/${domain}.log { mode 640 }";
|
||||
extraConfig = ''
|
||||
bind tailscale/${subdomainOf domain}
|
||||
bind tailscale/${lib.custom.subdomainOf domain}
|
||||
reverse_proxy localhost:${toString port}
|
||||
'';
|
||||
};
|
||||
|
|
@ -150,7 +147,7 @@ in
|
|||
'';
|
||||
virtualHosts =
|
||||
nonTailscaleHosts
|
||||
|> lib.groupBy (value: rootDomainOf value.domain)
|
||||
|> lib.groupBy (value: lib.custom.rootDomainOf value.domain)
|
||||
|> lib.mapAttrs' mkWildCardDomain;
|
||||
};
|
||||
})
|
||||
|
|
|
|||
|
|
@ -101,8 +101,6 @@ in
|
|||
|
||||
custom.services.gatus.endpoints =
|
||||
let
|
||||
getSubdomain = domain: domain |> lib.splitString "." |> lib.head;
|
||||
|
||||
defaultEndpoints =
|
||||
self.nixosConfigurations
|
||||
|> lib.mapAttrs (_: value: value.config.meta.domains.list)
|
||||
|
|
@ -112,7 +110,7 @@ in
|
|||
|> lib.filter (domain: domain != cfg.domain)
|
||||
|> lib.map (
|
||||
domain:
|
||||
lib.nameValuePair (getSubdomain domain) {
|
||||
lib.nameValuePair (lib.custom.subdomainOf domain) {
|
||||
inherit domain;
|
||||
group = hostName;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue