From cad10a31eb553cc4a7f99d693e27b96f6ca3a4ae Mon Sep 17 00:00:00 2001 From: "Casper V. Kristensen" Date: Sat, 24 Feb 2024 16:43:10 +0100 Subject: [PATCH] split network configuration from default.nix --- hosts/alpha/default.nix | 13 +------------ hosts/alpha/network.nix | 14 ++++++++++++++ hosts/tor/default.nix | 16 +--------------- hosts/tor/network.nix | 17 +++++++++++++++++ 4 files changed, 33 insertions(+), 27 deletions(-) create mode 100644 hosts/alpha/network.nix create mode 100644 hosts/tor/network.nix diff --git a/hosts/alpha/default.nix b/hosts/alpha/default.nix index f195532..32afb6d 100644 --- a/hosts/alpha/default.nix +++ b/hosts/alpha/default.nix @@ -4,21 +4,10 @@ ../../modules/base ../../modules/server ./hardware.nix + ./network.nix ]; networking.hostName = "alpha"; - systemd.network.networks = { - "10-lan" = { - name = "enp1s0"; - networkConfig.DHCP = "ipv4"; - address = [ - "2a01:4f8:c2c:71c0::/64" - ]; - routes = [ - { routeConfig = { Gateway = "fe80::1"; }; } - ]; - }; - }; boot = { loader = { diff --git a/hosts/alpha/network.nix b/hosts/alpha/network.nix new file mode 100644 index 0000000..68c6863 --- /dev/null +++ b/hosts/alpha/network.nix @@ -0,0 +1,14 @@ +{ ... }: { + systemd.network.networks = { + "10-lan" = { + name = "enp1s0"; + networkConfig.DHCP = "ipv4"; + address = [ + "2a01:4f8:c2c:71c0::/64" + ]; + routes = [ + { routeConfig = { Gateway = "fe80::1"; }; } + ]; + }; + }; +} diff --git a/hosts/tor/default.nix b/hosts/tor/default.nix index 7ff04c4..780404e 100644 --- a/hosts/tor/default.nix +++ b/hosts/tor/default.nix @@ -5,25 +5,11 @@ ../../modules/server ../../modules/tor ./hardware.nix + ./network.nix ./tor.nix ]; networking.hostName = "tor"; - systemd.network.networks = { - "10-lan" = { - # IPv4 settings are from `sudo dhcpcd --test`. - # IPv6 settings are from https://www.ssdvps.dk/knowledgebase/18/IPv6-Gateway.html. - name = "ens3"; - address = [ - "91.210.59.57/25" - "2a0d:3e83:1:b284::1/64" - ]; - routes = [ - { routeConfig = { Gateway = "91.210.59.1"; }; } - { routeConfig = { Gateway = "2a0d:3e83:1::1"; GatewayOnLink = true; }; } - ]; - }; - }; boot = { loader = { diff --git a/hosts/tor/network.nix b/hosts/tor/network.nix new file mode 100644 index 0000000..1217719 --- /dev/null +++ b/hosts/tor/network.nix @@ -0,0 +1,17 @@ +{ ... }: { + systemd.network.networks = { + "10-lan" = { + # IPv4 settings are from `sudo dhcpcd --test`. + # IPv6 settings are from https://www.ssdvps.dk/knowledgebase/18/IPv6-Gateway.html. + name = "ens3"; + address = [ + "91.210.59.57/25" + "2a0d:3e83:1:b284::1/64" + ]; + routes = [ + { routeConfig = { Gateway = "91.210.59.1"; }; } + { routeConfig = { Gateway = "2a0d:3e83:1::1"; GatewayOnLink = true; }; } + ]; + }; + }; +}