Compare commits

...

8 Commits

Author SHA1 Message Date
Giulio De Pasquale
7cf37954ef headscale: use architect options 2024-01-31 00:33:56 +01:00
Giulio De Pasquale
946e185c99 prowlarr: use unstable pkg 2024-01-31 00:23:11 +01:00
Giulio De Pasquale
64e4f375a9 nginx: do not use openTCPVPN 2024-01-31 00:22:55 +01:00
Giulio De Pasquale
8c0a902945 options: cleanup, move dns into dns 2024-01-31 00:22:24 +01:00
Giulio De Pasquale
8ce5e14da2 radarr: use unstable pkg 2024-01-31 00:21:07 +01:00
Giulio De Pasquale
76c5783fe8 sonarr: use unstable pkg 2024-01-31 00:20:47 +01:00
Giulio De Pasquale
ffe2289c0d tailscale: update hosts 2024-01-31 00:20:27 +01:00
Giulio De Pasquale
aa12bece7f dns: use coredns for https records 2024-01-31 00:20:07 +01:00
8 changed files with 89 additions and 107 deletions

View File

@ -1,40 +1,49 @@
{ config, pkgs, lib, ... }: { config, lib, ... }:
let let
domain = "adguard.architect.devs.giugl.io"; # Function to generate CoreDNS config for a single vhost
generateCoreDNSConfigForVhost = domain: conf:
let
# Retrieve architect's IP on each interface
interfaceConfigs = builtins.map
(iface:
let
architectIP = config.architect.networks.${iface}.devices.architect.address;
interfaceNet = config.architect.networks.${iface}.net;
in
''
${domain} {
view ${iface} {
expr incidr(client_ip(), '${interfaceNet}')
}
template IN A ${domain} {
answer "${domain}. 60 IN A ${architectIP}"
}
template IN HTTPS ${domain} {
answer "${domain}. 60 IN HTTPS 1 . ipv4hint=\"${architectIP}\""
}
cache
log
}
''
)
conf.dnsInterfaces;
in
lib.concatStringsSep "\n" interfaceConfigs;
in in
{ {
architect = {
firewall.openUDPVPN = [ 53 ];
vhost.${domain} = {
dnsInterfaces = [ "lan" "tailscale" ];
locations."/" = with config; {
port = services.adguardhome.settings.bind_port;
allow = with architect.networks; [ lan.net tailscale.net ];
deny = [
architect.networks."lan".devices.router.address
];
};
};
};
services = { services = {
dnsmasq = { coredns = {
enable = true; enable = true;
settings = { config = ''
server = [ "127.0.0.1#${toString config.services.adguardhome.settings.dns.port}" ]; ${lib.concatStringsSep "\n" (lib.mapAttrsToList generateCoreDNSConfigForVhost config.architect.vhost)}
localise-queries = true;
min-cache-ttl = 120; . {
max-cache-ttl = 2400; cache
domain = [ forward . 127.0.0.1:${toString config.services.adguardhome.settings.dns.port}
"runas.rocks" }
"giugl.io" '';
"devs.runas.rocks"
"devs.giugl.io"
];
};
}; };
adguardhome = { adguardhome = {

View File

@ -1,53 +1,46 @@
{ config, pkgs, lib, ... }: { config, pkgs, ... }:
let let
domain = "vipienne.giugl.io"; baseDomain = "giugl.io";
domain = "vipienne.${baseDomain}";
headscalePkg = pkgs.unstablePkgs.headscale;
in in
{ {
environment.systemPackages = [ pkgs.headscale ]; environment.systemPackages = [ headscalePkg ];
architect.firewall = { architect = {
openUDP = [ config.services.tailscale.port ]; firewall = {
}; openUDP = [ config.services.tailscale.port ];
services = {
headscale = {
enable = true;
package = pkgs.unstablePkgs.headscale;
port = 1194;
address = "0.0.0.0";
settings = {
server_url = "https://${domain}";
log.level = "debug";
dns_config = {
magic_dns = true;
base_domain = "giugl.io";
override_local_dns = true;
nameservers = [ config.architect.networks.tailscale.devices.architect.address ];
};
logtail.enabled = false;
ip_prefixes = [ config.architect.networks.tailscale.net ];
noise.private_key_path = "/var/lib/headscale/noise_private.key";
};
}; };
nginx.virtualHosts.${domain} = { vhost.${domain} = {
forceSSL = true; dnsInterfaces = [ "lan" "tailscale" ];
enableACME = true;
extraConfig = ''
ssl_protocols TLSv1.2 TLSv1.3;
'';
locations."/" = { locations."/" = {
proxyPass = port = config.services.headscale.port;
"http://127.0.0.1:${toString config.services.headscale.port}"; allowWAN = true;
proxyWebsockets = true; proxyWebsockets = true;
recommendedProxySettings = true;
extraConfig = ''
proxy_buffering off;
add_header Strict-Transport-Security "max-age=15552000; includeSubDomains" always;
'';
}; };
}; };
}; };
services.headscale = {
enable = true;
package = headscalePkg;
settings = {
server_url = "https://${domain}";
log.level = "debug";
dns_config = {
magic_dns = false;
base_domain = baseDomain;
override_local_dns = true;
nameservers = [
config.architect.networks.tailscale.devices.architect.address
];
};
logtail.enabled = false;
ip_prefixes = [ config.architect.networks.tailscale.net ];
noise.private_key_path = "/var/lib/headscale/noise_private.key";
};
};
} }

View File

@ -3,7 +3,6 @@
{ {
architect.firewall = { architect.firewall = {
openTCP = [ 80 443 ]; openTCP = [ 80 443 ];
openTCPVPN = [ 80 443 ];
}; };
services.nginx = { services.nginx = {

View File

@ -2,10 +2,6 @@
with lib; with lib;
let
utilities = import ./utilities.nix { inherit lib config; };
inherit (utilities) architectInterfaceAddress;
in
{ {
options.architect = { options.architect = {
firewall = { firewall = {
@ -17,14 +13,6 @@ in
type = types.listOf types.int; type = types.listOf types.int;
default = [ ]; default = [ ];
}; };
openTCPVPN = mkOption {
type = types.listOf types.int;
default = [ ];
};
openUDPVPN = mkOption {
type = types.listOf types.int;
default = [ ];
};
}; };
networks = mkOption { networks = mkOption {
@ -118,12 +106,6 @@ in
default = false; default = false;
description = "If set to false, deny all WAN traffic."; description = "If set to false, deny all WAN traffic.";
}; };
deny = mkOption {
type = types.listOf types.str;
default = [ ];
description = "IP address or CIDR block to deny.";
};
}; };
}); });
default = { }; default = { };
@ -136,6 +118,7 @@ in
}; };
}; };
# TODO: move to nginx
config = { config = {
services.nginx.virtualHosts = mapAttrs services.nginx.virtualHosts = mapAttrs
(domain: conf: { (domain: conf: {
@ -147,21 +130,12 @@ in
proxyWebsockets = location.proxyWebsockets; proxyWebsockets = location.proxyWebsockets;
extraConfig = '' extraConfig = ''
${concatMapStringsSep "\n" (allowCIDR: "allow ${allowCIDR};") location.allow} ${concatMapStringsSep "\n" (allowCIDR: "allow ${allowCIDR};") location.allow}
${optionalString (!location.allowWAN) "deny all;"}
${concatMapStringsSep "\n" (denyCIDR: "deny ${denyCIDR};") location.deny}
${optionalString location.allowLan ''allow ${config.architect.networks."lan".net};''} ${optionalString location.allowLan ''allow ${config.architect.networks."lan".net};''}
${optionalString (!location.allowWAN) "deny all;"}
'' + location.extraConfig; '' + location.extraConfig;
}) })
conf.locations; conf.locations;
}) })
config.architect.vhost; config.architect.vhost;
networking.extraHosts = concatStringsSep "\n" (
mapAttrsToList
(domain: conf: concatMapStringsSep "\n"
(iface: "${architectInterfaceAddress iface} ${domain}")
conf.dnsInterfaces)
config.architect.vhost
);
}; };
} }

View File

@ -1,10 +1,13 @@
{ config, ... }: { config, pkgs, ... }:
let let
domain = "htpro.giugl.io"; domain = "htpro.giugl.io";
in in
{ {
services.prowlarr.enable = true; services.prowlarr = {
enable = true;
package = pkgs.unstablePkgs.prowlarr;
};
architect.vhost.${domain} = with config.architect.networks; { architect.vhost.${domain} = with config.architect.networks; {
dnsInterfaces = [ "tailscale" ]; dnsInterfaces = [ "tailscale" ];

View File

@ -1,4 +1,4 @@
{ config, lib, ... }: { config, pkgs, ... }:
let let
domain = "htrad.giugl.io"; domain = "htrad.giugl.io";
@ -6,6 +6,7 @@ in
{ {
services.radarr = { services.radarr = {
enable = true; enable = true;
package = pkgs.unstablePkgs.radarr;
group = "media"; group = "media";
}; };

View File

@ -1,4 +1,4 @@
{ config, lib, ... }: { config, pkgs, ... }:
let let
domain = "htson.giugl.io"; domain = "htson.giugl.io";
@ -7,6 +7,7 @@ in
services.sonarr = { services.sonarr = {
enable = true; enable = true;
group = "media"; group = "media";
package = pkgs.unstablePkgs.sonarr;
}; };
architect.vhost.${domain} = with config.architect.networks; { architect.vhost.${domain} = with config.architect.networks; {

View File

@ -15,14 +15,16 @@ in
devices = { devices = {
architect = { address = "100.64.0.1"; hostname = "architect.${domain}"; }; architect = { address = "100.64.0.1"; hostname = "architect.${domain}"; };
kmerr = { address = "100.64.0.2"; hostname = "kmerr.${domain}"; }; kmerr = { address = "100.64.0.2"; hostname = "kmerr.${domain}"; };
parallels = { address = "100.64.0.3"; hostname = "parallels.${domain}"; };
chuck = { address = "100.64.0.4"; hostname = "chuck.${domain}"; }; chuck = { address = "100.64.0.4"; hostname = "chuck.${domain}"; };
dodino = { address = "100.64.0.5"; hostname = "dodino.${domain}"; }; dodino = { address = "100.64.0.5"; hostname = "dodino.${domain}"; };
manduria = { address = "100.64.0.6"; hostname = "manduria.${domain}"; }; manduria = { address = "100.64.0.6"; hostname = "manduria.${domain}"; };
tommy = { address = "100.64.0.7"; hostname = "tommy.${domain}"; }; tommy = { address = "100.64.0.7"; hostname = "tommy.${domain}"; };
# ucsb-workstation = { address = "100.64.0.8"; hostname = "ucsb-workstation.${domain}"; }; ucsb-workstation = { address = "100.64.0.8"; hostname = "ucsb-workstation.${domain}"; };
ucsb-workstation = { address = "100.64.0.10"; hostname = "ucsb-workstation.${domain}"; };
alfredo = { address = "100.64.0.9"; hostname = "alfredo.${domain}"; }; alfredo = { address = "100.64.0.9"; hostname = "alfredo.${domain}"; };
parallels = { address = "100.64.0.3"; hostname = "parallels.${domain}"; }; appletv = { address = "100.64.0.13"; hostname = "appletv.${domain}"; };
watkinshouse = { address = "100.64.0.14"; hostname = "watkinshouse.${domain}"; };
afsun = { address = "100.64.0.15"; hostname = "afsun.${domain}"; };
}; };
}; };
}; };