all: refactor app configs

This commit is contained in:
Adithya 2024-09-14 19:55:57 +05:30
parent 29555fda8b
commit 679761e70c
Signed by: adtya
GPG key ID: B8857BFBA2C47B9C
10 changed files with 107 additions and 47 deletions

View file

@ -1,7 +1,13 @@
_: { _:
let
inherit (import ../../../shared/caddy-helpers.nix) logFormat;
domainName = "alertmanager.labs.adtya.xyz";
in
{
services = { services = {
caddy = { caddy = {
virtualHosts."alertmanager.labs.adtya.xyz" = { virtualHosts."${domainName}" = {
logFormat = logFormat "${domainName}";
extraConfig = '' extraConfig = ''
reverse_proxy 127.0.0.1:9093 reverse_proxy 127.0.0.1:9093
''; '';
@ -11,7 +17,7 @@ _: {
enable = true; enable = true;
listenAddress = "127.0.0.1"; listenAddress = "127.0.0.1";
port = 9093; port = 9093;
webExternalUrl = "https://alertmanager.labs.adtya.xyz/"; webExternalUrl = "https://${domainName}/";
configuration = { configuration = {
route = { route = {
group_by = [ "alertname" ]; group_by = [ "alertname" ];

View file

@ -1,4 +1,9 @@
_: { _:
let
inherit (import ../../../shared/caddy-helpers.nix) logFormat;
domainName = "block.labs.adtya.xyz";
in
{
networking = { networking = {
firewall = { firewall = {
allowedTCPPorts = [ allowedTCPPorts = [
@ -12,7 +17,8 @@ _: {
systemd.services.blocky.unitConfig.After = [ "network-online.target" "wireguard-wg0.service" ]; systemd.services.blocky.unitConfig.After = [ "network-online.target" "wireguard-wg0.service" ];
services = { services = {
caddy = { caddy = {
virtualHosts."blocky.labs.adtya.xyz" = { virtualHosts."${domainName}" = {
logFormat = logFormat domainName;
extraConfig = '' extraConfig = ''
reverse_proxy 127.0.0.1:8080 reverse_proxy 127.0.0.1:8080
''; '';

View file

@ -1,7 +1,13 @@
_: { _:
let
inherit (import ../../../shared/caddy-helpers.nix) logFormat;
domainName = "grafana.labs.adtya.xyz";
in
{
services = { services = {
caddy = { caddy = {
virtualHosts."grafana.labs.adtya.xyz" = { virtualHosts."${domainName}" = {
logFormat = logFormat domainName;
extraConfig = '' extraConfig = ''
reverse_proxy 127.0.0.1:9091 reverse_proxy 127.0.0.1:9091
''; '';
@ -11,7 +17,7 @@ _: {
enable = true; enable = true;
settings = { settings = {
server = { server = {
domain = "grafana.labs.adtya.xyz"; domain = domainName;
http_addr = "127.0.0.1"; http_addr = "127.0.0.1";
http_port = 9091; http_port = 9091;
}; };

View file

@ -1,7 +1,13 @@
_: { _:
let
inherit (import ../../../shared/caddy-helpers.nix) logFormat;
domainName = "loki.labs.adtyz.xyz";
in
{
services = { services = {
caddy = { caddy = {
virtualHosts."loki.labs.adtya.xyz" = { virtualHosts."${domainName}" = {
logFormat = logFormat domainName;
extraConfig = '' extraConfig = ''
reverse_proxy 127.0.0.1:3100 reverse_proxy 127.0.0.1:3100
''; '';

View file

@ -1,7 +1,13 @@
_: { _:
let
inherit (import ../../../shared/caddy-helpers.nix) logFormat;
domainName = "prometheus.labs.adtya.xyz";
in
{
services = { services = {
caddy = { caddy = {
virtualHosts."prometheus.labs.adtya.xyz" = { virtualHosts."${domainName}" = {
logFormat = logFormat domainName;
extraConfig = '' extraConfig = ''
reverse_proxy 127.0.0.1:9090 reverse_proxy 127.0.0.1:9090
''; '';

View file

@ -1,7 +1,13 @@
{ inputs, pkgs, ... }: { { inputs, pkgs, ... }:
let
inherit (import ../../../shared/caddy-helpers.nix) logFormat;
domainName = "adtya.xyz";
in
{
services = { services = {
caddy.virtualHosts."adtya.xyz" = { caddy.virtualHosts."${domainName}" = {
serverAliases = [ "www.adtya.xyz" ]; serverAliases = [ "www.${domainName}" ];
logFormat = logFormat domainName;
extraConfig = '' extraConfig = ''
handle { handle {
root * ${inputs.adtyaxyz.packages.${pkgs.system}.default}/share/web root * ${inputs.adtyaxyz.packages.${pkgs.system}.default}/share/web
@ -13,16 +19,16 @@
}; };
frp.settings.proxies = [ frp.settings.proxies = [
{ {
name = "http.adtya.xyz"; name = "http.${domainName}";
type = "http"; type = "http";
customDomains = [ "adtya.xyz" "www.adtya.xyz" ]; customDomains = [ "${domainName}" "www.${domainName}" ];
localPort = 80; localPort = 80;
transport.useCompression = true; transport.useCompression = true;
} }
{ {
name = "https.adtya.xyz"; name = "https.${domainName}";
type = "https"; type = "https";
customDomains = [ "adtya.xyz" "www.adtya.xyz" ]; customDomains = [ "${domainName}" "www.${domainName}" ];
localPort = 443; localPort = 443;
transport.useCompression = true; transport.useCompression = true;
} }

View file

@ -1,7 +1,13 @@
_: { _:
let
inherit (import ../../../shared/caddy-helpers.nix) logFormat;
domainName = "proofs.adtya.xyz";
in
{
services = { services = {
caddy.virtualHosts = { caddy.virtualHosts = {
"proofs.adtya.xyz" = { "${domainName}" = {
logFormat = logFormat domainName;
extraConfig = '' extraConfig = ''
redir https://keyoxide.org/hkp/51E4F5AB1B82BE45B4229CC243A5E25AA5A27849 redir https://keyoxide.org/hkp/51E4F5AB1B82BE45B4229CC243A5E25AA5A27849
''; '';
@ -10,16 +16,16 @@ _: {
frp.settings.proxies = [ frp.settings.proxies = [
{ {
name = "http.proofs.adtya.xyz"; name = "http.${domainName}";
type = "http"; type = "http";
customDomains = [ "proofs.adtya.xyz" ]; customDomains = [ "${domainName}" ];
localPort = 80; localPort = 80;
transport.useCompression = true; transport.useCompression = true;
} }
{ {
name = "https.proofs.adtya.xyz"; name = "https.${domainName}";
type = "https"; type = "https";
customDomains = [ "proofs.adtya.xyz" ]; customDomains = [ "${domainName}" ];
localPort = 443; localPort = 443;
transport.useCompression = true; transport.useCompression = true;
} }

View file

@ -1,6 +1,12 @@
{ inputs, pkgs, ... }: { { inputs, pkgs, ... }:
let
inherit (import ../../../shared/caddy-helpers.nix) logFormat;
domainName = "wiki.adtya.xyz";
in
{
services = { services = {
caddy.virtualHosts."wiki.adtya.xyz" = { caddy.virtualHosts."${domainName}" = {
logFormat = logFormat domainName;
extraConfig = '' extraConfig = ''
handle { handle {
root * ${inputs.wiki.packages.${pkgs.system}.default}/share/web root * ${inputs.wiki.packages.${pkgs.system}.default}/share/web
@ -12,16 +18,16 @@
}; };
frp.settings.proxies = [ frp.settings.proxies = [
{ {
name = "http.wiki.adtya.xyz"; name = "http.${domainName}";
type = "http"; type = "http";
customDomains = [ "wiki.adtya.xyz" ]; customDomains = [ "${domainName}" ];
localPort = 80; localPort = 80;
transport.useCompression = true; transport.useCompression = true;
} }
{ {
name = "https.wiki.adtya.xyz"; name = "https.${domainName}";
type = "https"; type = "https";
customDomains = [ "wiki.adtya.xyz" ]; customDomains = [ "${domainName}" ];
localPort = 443; localPort = 443;
transport.useCompression = true; transport.useCompression = true;
} }

View file

@ -1,32 +1,38 @@
_: { _:
let
inherit (import ../../../shared/caddy-helpers.nix) logFormat;
domainName = "acomputer.lol";
in
{
services = { services = {
caddy.virtualHosts."acomputer.lol" = { caddy.virtualHosts."${domainName}" = {
logFormat = logFormat domainName;
extraConfig = '' extraConfig = ''
handle /.well-known/matrix/server { handle /.well-known/matrix/server {
header Content-Type application/json header Content-Type application/json
header Access-Control-Allow-Origin * header Access-Control-Allow-Origin *
respond `{"m.server": "matrix.acomputer.lol:443"}` respond `{"m.server": "matrix.${domainName}:443"}`
} }
handle /.well-known/matrix/client { handle /.well-known/matrix/client {
header Content-Type application/json header Content-Type application/json
header Access-Control-Allow-Origin * header Access-Control-Allow-Origin *
respond `{"m.homeserver": {"base_url": "https://matrix.acomputer.lol:443"}, "org.matrix.msc3575.proxy": {"url": "https://matrix.acomputer.lol"}}` respond `{"m.homeserver": {"base_url": "https://matrix.${domainName}:443"}, "org.matrix.msc3575.proxy": {"url": "https://matrix.${domainName}"}}`
} }
''; '';
}; };
frp.settings.proxies = [ frp.settings.proxies = [
{ {
name = "http.acomputer.lol"; name = "http.${domainName}";
type = "http"; type = "http";
customDomains = [ "acomputer.lol" ]; customDomains = [ "${domainName}" ];
localPort = 80; localPort = 80;
transport.useCompression = true; transport.useCompression = true;
} }
{ {
name = "https.acomputer.lol"; name = "https.${domainName}";
type = "https"; type = "https";
customDomains = [ "acomputer.lol" ]; customDomains = [ "${domainName}" ];
localPort = 443; localPort = 443;
transport.useCompression = true; transport.useCompression = true;
} }

View file

@ -1,15 +1,21 @@
{ config, pkgs, ... }: { { config, pkgs, ... }:
let
inherit (import ../../../../shared/caddy-helpers.nix) logFormat;
domainName = "matrix.acomputer.lol";
in
{
sops = { sops = {
secrets = { secrets = {
"matrix/syncv3_secret" = { "matrix/syncv3_secret" = {
mode = "444"; mode = "444";
owner = config.users.users.root.name; owner = config.users.users.root.name;
group = config.users.users.root.group; inherit (config.users.users.root) group;
}; };
}; };
}; };
services = { services = {
caddy.virtualHosts."matrix.acomputer.lol" = { caddy.virtualHosts."${domainName}" = {
logFormat = logFormat domainName;
extraConfig = '' extraConfig = ''
reverse_proxy /client/* 127.0.0.1:8009 reverse_proxy /client/* 127.0.0.1:8009
reverse_proxy /_matrix/client/unstable/org.matrix.msc3575/sync 127.0.0.1:8009 reverse_proxy /_matrix/client/unstable/org.matrix.msc3575/sync 127.0.0.1:8009
@ -20,16 +26,16 @@
}; };
frp.settings.proxies = [ frp.settings.proxies = [
{ {
name = "http.matrix.acomputer.lol"; name = "http.${domainName}";
type = "http"; type = "http";
customDomains = [ "matrix.acomputer.lol" ]; customDomains = [ "${domainName}" ];
localPort = 80; localPort = 80;
transport.useCompression = true; transport.useCompression = true;
} }
{ {
name = "https.matrix.acomputer.lol"; name = "https.${domainName}";
type = "https"; type = "https";
customDomains = [ "matrix.acomputer.lol" ]; customDomains = [ "${domainName}" ];
localPort = 443; localPort = 443;
transport.useCompression = true; transport.useCompression = true;
} }
@ -37,7 +43,7 @@
matrix-sliding-sync = { matrix-sliding-sync = {
enable = true; enable = true;
settings = { settings = {
SYNCV3_SERVER = "https://matrix.acomputer.lol"; SYNCV3_SERVER = "https://${domainName}";
SYNCV3_BINDADDR = "127.0.0.1:8009"; SYNCV3_BINDADDR = "127.0.0.1:8009";
SYNCV3_DB = "postgresql://dendrite@localhost/dendrite?sslmode=disable"; SYNCV3_DB = "postgresql://dendrite@localhost/dendrite?sslmode=disable";
}; };