feat(meta): get vpn-ip, wg-key and subnets

This commit is contained in:
catvayor 2025-01-06 15:29:31 +01:00
parent 01af00470d
commit e8f8a54b5d
Signed by: lbailly
GPG key ID: CE3E645251AC63F3
20 changed files with 88 additions and 44 deletions

View file

@ -15,7 +15,6 @@ let
mkDefault mkDefault
; ;
inherit (lib.types) inherit (lib.types)
str
package package
; ;
in in
@ -31,12 +30,6 @@ in
addArgs = mkEnableOption "the extra arguments" // { addArgs = mkEnableOption "the extra arguments" // {
default = true; default = true;
}; };
wireguardPubKey = mkOption {
type = str;
};
fqdn = mkOption {
type = str;
};
anywhere = mkOption { anywhere = mkOption {
type = package; type = package;
readOnly = true; readOnly = true;

View file

@ -16,6 +16,8 @@ let
enum enum
path path
unspecified unspecified
nullOr
str
; ;
machine_meta = machine_meta =
@ -37,13 +39,37 @@ let
default = [ ]; default = [ ];
# /!\ Take care of imported files # /!\ Take care of imported files
}; };
wg-key = mkOption {
type = nullOr str;
default = null;
};
vpn-ip4 = mkOption {
type = nullOr str;
default = null;
};
subnets = mkOption {
type = listOf str;
default = [ ];
};
fqdn = mkOption {
type = nullOr str;
default = null;
};
node_meta = mkOption { node_meta = mkOption {
type = unspecified; type = unspecified;
readOnly = true; readOnly = true;
}; };
}; };
config.node_meta = rec { config.node_meta = rec {
inherit (config) version; inherit (config)
version
wg-key
vpn-ip4
subnets
fqdn
;
patches = [ ./nginx-fallback.patch ] ++ config.patches; patches = [ ./nginx-fallback.patch ] ++ config.patches;
overlay-paths = [ "${sources.kat-pkgs}/overlay.nix" ] ++ config.overlay-paths; overlay-paths = [ "${sources.kat-pkgs}/overlay.nix" ] ++ config.overlay-paths;
nixpkgs-paths = { nixpkgs-paths = {

View file

@ -2,6 +2,8 @@
pkgs, pkgs,
lib, lib,
config, config,
self-meta,
meta,
nodes ? { }, nodes ? { },
... ...
}: }:
@ -36,7 +38,7 @@ let
internal = port; internal = port;
}) (submodule redirected-ports-mod); }) (submodule redirected-ports-mod);
inherit (config.kat) fqdn; inherit (self-meta) fqdn;
hostname = config.networking.hostName; hostname = config.networking.hostName;
cfg = config.kat.proxies; cfg = config.kat.proxies;
@ -66,7 +68,7 @@ let
map ( map (
host: host:
let let
inherit (nodes.${host}.config.kat) fqdn; inherit (meta.machines.${host}) fqdn;
host-cfg = nodes.${host}.config.kat.proxies; host-cfg = nodes.${host}.config.kat.proxies;
in in
{ {

View file

@ -22,8 +22,7 @@ in
users.users.root.openssh.authorizedKeys.keys = ssh-keys.sylvain; users.users.root.openssh.authorizedKeys.keys = ssh-keys.sylvain;
kat = { kat = {
fqdn = "betamail.katvayor.net"; # wireguardPubKey = "Znj451+hGJcPV1zFgpRMA8hg8edmUInA5zBtYBUuL3k=";
wireguardPubKey = "Znj451+hGJcPV1zFgpRMA8hg8edmUInA5zBtYBUuL3k=";
proxies = { proxies = {
ip = "192.168.122.3"; ip = "192.168.122.3";
aliases = [ "catvayor.sh" ]; aliases = [ "catvayor.sh" ];

View file

@ -2,6 +2,8 @@
meta = { meta = {
version = "unstable"; version = "unstable";
patches = [ ./0001-revert-procmail-to-3.22.patch ]; patches = [ ./0001-revert-procmail-to-3.22.patch ];
fqdn = "betamail.katvayor.net";
vpn-ip4 = "192.168.122.3";
}; };
config = import ./configuration.nix; config = import ./configuration.nix;
} }

View file

@ -1,4 +1,7 @@
{ {
meta.version = "unstable"; meta = {
version = "unstable";
vpn-ip4 = "192.168.122.8";
};
config = import ./configuration.nix; config = import ./configuration.nix;
} }

View file

@ -20,7 +20,6 @@
}; };
kat = { kat = {
fqdn = "degette.katvayor.net";
proxies = { proxies = {
ip = "192.168.122.2"; ip = "192.168.122.2";
open-tcp = [ open-tcp = [

View file

@ -1,4 +1,8 @@
{ {
meta.version = "stable"; meta = {
version = "stable";
fqdn = "degette.katvayor.net";
vpn-ip4 = "192.168.122.2";
};
config = import ./configuration.nix; config = import ./configuration.nix;
} }

View file

@ -1,6 +1,6 @@
{ {
pkgs, pkgs,
nodes, meta,
... ...
}: }:
{ {
@ -23,7 +23,6 @@
}; };
kat = { kat = {
fqdn = "manah.katvayor.net";
proxies = { proxies = {
ip = "10.42.0.1"; ip = "10.42.0.1";
open-tcp = [ open-tcp = [
@ -38,7 +37,6 @@
"kat-betamail" "kat-betamail"
]; ];
}; };
wireguardPubKey = "2rMQV5fyBhl7t/0j70iPOfEr/lAWQfLXQKMwtzaXxnM=";
}; };
systemd.network = { systemd.network = {
@ -92,12 +90,12 @@
wireguardPeers = [ wireguardPeers = [
{ {
Endpoint = "watcher.katvayor.net:1194"; Endpoint = "${meta.machines.kat-watcher.fqdn}:1194";
AllowedIPs = [ AllowedIPs = [
"10.42.0.2/32" "10.42.0.2/32"
]; ];
PersistentKeepalive = 20; PersistentKeepalive = 20;
PublicKey = nodes.kat-watcher.config.kat.wireguardPubKey; PublicKey = meta.machines.kat-watcher.wg-key;
} }
]; ];
}; };

View file

@ -1,4 +1,13 @@
{ {
meta.version = "unstable"; meta = {
version = "unstable";
fqdn = "manah.katvayor.net";
vpn-ip4 = "10.42.0.1";
wg-key = "2rMQV5fyBhl7t/0j70iPOfEr/lAWQfLXQKMwtzaXxnM=";
subnets = [
"192.168.1.0/24"
"192.168.122.0/24"
];
};
config = import ./configuration.nix; config = import ./configuration.nix;
} }

View file

@ -27,7 +27,6 @@
}; };
kat = { kat = {
fqdn = "orchid.katvayor.net";
proxies = { proxies = {
ip = "192.168.122.6"; ip = "192.168.122.6";
aliases = [ aliases = [

View file

@ -1,4 +1,8 @@
{ {
meta.version = "stable"; meta = {
version = "stable";
fqdn = "orchid.katvayor.net";
vpn-ip4 = "192.168.122.6";
};
config = import ./configuration.nix; config = import ./configuration.nix;
} }

View file

@ -1,6 +1,6 @@
{ {
pkgs, pkgs,
nodes, meta,
users, users,
lib, lib,
sources, sources,
@ -55,7 +55,6 @@ in
"wg0" "wg0"
]; ];
}; };
kat.wireguardPubKey = "zIHvCSzk5a94jvnXU4iscbp9RUGzbWpARDMRgHNtMl4=";
systemd.tmpfiles.rules = [ systemd.tmpfiles.rules = [
"w /sys/devices/system/cpu/cpufreq/policy*/scaling_governor - - - - performance" "w /sys/devices/system/cpu/cpufreq/policy*/scaling_governor - - - - performance"
"w /sys/devices/system/cpu/cpufreq/policy*/energy_performance_preference - - - - performance" "w /sys/devices/system/cpu/cpufreq/policy*/energy_performance_preference - - - - performance"
@ -99,8 +98,8 @@ in
AllowedIPs = [ AllowedIPs = [
"10.42.0.0/16" "10.42.0.0/16"
]; ];
PublicKey = nodes.kat-watcher.config.kat.wireguardPubKey; PublicKey = meta.machines.kat-watcher.wg-key;
Endpoint = "watcher.katvayor.net:1194"; Endpoint = "${meta.machines.kat-watcher.fqdn}:1194";
PersistentKeepalive = 25; PersistentKeepalive = 25;
} }
]; ];

View file

@ -1,4 +1,8 @@
{ {
meta.version = "unstable"; meta = {
version = "unstable";
wg-key = "zIHvCSzk5a94jvnXU4iscbp9RUGzbWpARDMRgHNtMl4=";
vpn-ip4 = "10.42.1.1";
};
config = import ./configuration.nix; config = import ./configuration.nix;
} }

View file

@ -22,7 +22,6 @@
}; };
kat = { kat = {
fqdn = "son.katvayor.net";
proxies = { proxies = {
ip = "192.168.122.5"; ip = "192.168.122.5";
aliases = [ aliases = [

View file

@ -1,4 +1,8 @@
{ {
meta.version = "unstable"; meta = {
version = "unstable";
fqdn = "son.katvayor.net";
vpn-ip4 = "192.168.122.5";
};
config = import ./configuration.nix; config = import ./configuration.nix;
} }

View file

@ -1,6 +1,6 @@
{ {
pkgs, pkgs,
nodes, meta,
... ...
}: }:
{ {
@ -21,8 +21,6 @@
}; };
kat = { kat = {
wireguardPubKey = "BgLBrWG7DRj2Gwoyj+vHZTjiB3gPEnwVcDFEQH/BYgg=";
fqdn = "watcher.katvayor.net";
proxies.redirects = [ "kat-manah" ]; proxies.redirects = [ "kat-manah" ];
}; };
@ -83,19 +81,13 @@
AllowedIPs = [ AllowedIPs = [
"10.42.0.1/32" "10.42.0.1/32"
]; ];
PublicKey = nodes.kat-manah.config.kat.wireguardPubKey; PublicKey = meta.machines.kat-manah.wg-key;
} }
{ {
AllowedIPs = [ AllowedIPs = [
"10.42.1.1/32" "10.42.1.1/32"
]; ];
PublicKey = nodes.kat-probook.config.kat.wireguardPubKey; PublicKey = meta.machines.kat-probook.wg-key;
}
{
AllowedIPs = [
"10.42.2.1/32"
];
PublicKey = nodes.kat-betamail.config.kat.wireguardPubKey;
} }
]; ];
}; };

View file

@ -1,4 +1,9 @@
{ {
meta.version = "unstable"; meta = {
version = "unstable";
wg-key = "BgLBrWG7DRj2Gwoyj+vHZTjiB3gPEnwVcDFEQH/BYgg=";
fqdn = "watcher.katvayor.net";
vpn-ip4 = "10.42.0.2";
};
config = import ./configuration.nix; config = import ./configuration.nix;
} }

View file

@ -24,7 +24,6 @@
}; };
kat = { kat = {
fqdn = "website.katvayor.net";
proxies = { proxies = {
aliases = [ aliases = [
"www.katvayor.net" "www.katvayor.net"

View file

@ -1,4 +1,8 @@
{ {
meta.version = "stable"; meta = {
version = "stable";
fqdn = "website.katvayor.net";
vpn-ip4 = "192.168.122.7";
};
config = import ./configuration.nix; config = import ./configuration.nix;
} }