Compare commits
8 Commits
ba39859e01
...
7cf37954ef
Author | SHA1 | Date | |
---|---|---|---|
|
7cf37954ef | ||
|
946e185c99 | ||
|
64e4f375a9 | ||
|
8c0a902945 | ||
|
8ce5e14da2 | ||
|
76c5783fe8 | ||
|
ffe2289c0d | ||
|
aa12bece7f |
@ -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 = {
|
||||||
|
@ -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";
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
{
|
{
|
||||||
architect.firewall = {
|
architect.firewall = {
|
||||||
openTCP = [ 80 443 ];
|
openTCP = [ 80 443 ];
|
||||||
openTCPVPN = [ 80 443 ];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
services.nginx = {
|
services.nginx = {
|
||||||
|
@ -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
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -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" ];
|
||||||
|
@ -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";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -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; {
|
||||||
|
@ -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}"; };
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user