From 5ca3265cc17bea668fb6c13f8a8b237d2dfbf2ca Mon Sep 17 00:00:00 2001 From: Brendan Golden Date: Wed, 18 Jun 2025 03:14:35 +0100 Subject: [PATCH] feat: fixed how sometimes updating servers mean that ye had to reset teh MAC address in Proxmox. This is done by letting each server manage its own network interface. --- applications/_base.nix | 24 ++++++++++++++++++++++++ machines/_base.nix | 6 +++++- machines/agentjones.nix | 14 +------------- machines/neuromancer.nix | 14 +------------- machines/skynet.nix | 2 ++ machines/vendetta.nix | 16 ++-------------- 6 files changed, 35 insertions(+), 41 deletions(-) diff --git a/applications/_base.nix b/applications/_base.nix index f96d7e4..c9f7f61 100644 --- a/applications/_base.nix +++ b/applications/_base.nix @@ -42,6 +42,16 @@ in { type = types.str; default = "${cfg.host.name}.skynet.ie"; }; + interface = mkOption { + type = types.str; + description = "Will most likely be ``eno1`` for physical servers."; + default = "eth0"; + }; + cidr = mkOption { + type = types.int; + description = "Most of our servers are /26, "; + default = 26; + }; }; }; @@ -60,6 +70,20 @@ in { } ]; + # set + networking = { + hostName = cfg.host.name; + defaultGateway.interface = lib.mkForce cfg.host.interface; + + # needs to have an address statically assigned + interfaces."${cfg.host.interface}".ipv4.addresses = [ + { + address = cfg.host.ip; + prefixLength = cfg.host.cidr; + } + ]; + }; + services.nginx = { virtualHosts = { # for every server unless explisitly defined redirect the ip to skynet.ie diff --git a/machines/_base.nix b/machines/_base.nix index 18da744..44dfadd 100644 --- a/machines/_base.nix +++ b/machines/_base.nix @@ -35,7 +35,11 @@ in { config = { # if its a lxc enable - proxmoxLXC.enable = cfg.lxc; + proxmoxLXC = { + enable = cfg.lxc; + manageNetwork = true; + manageHostName = true; + }; nix = { settings = { diff --git a/machines/agentjones.nix b/machines/agentjones.nix index 1fb3c4e..2c1ae09 100644 --- a/machines/agentjones.nix +++ b/machines/agentjones.nix @@ -21,6 +21,7 @@ Notes: Used to have Agent Smith as a partner but it died (Ironically) ip = ip_pub; name = name; hostname = hostname; + interface = "en01"; }; in { imports = [ @@ -44,19 +45,6 @@ in { # keep the wired usb connection alive (front panel) # networking.interfaces.enp0s29u1u5u2.useDHCP = true; - networking.hostName = name; - # this has to be defined for any physical servers - # vms are defined by teh vm host - networking = { - defaultGateway.interface = lib.mkForce "eno1"; - interfaces.eno1.ipv4.addresses = [ - { - address = ip_pub; - prefixLength = 26; - } - ]; - }; - # this server is teh firewall skynet_firewall = { # always good to know oneself diff --git a/machines/neuromancer.nix b/machines/neuromancer.nix index 6e2cbd9..7068310 100644 --- a/machines/neuromancer.nix +++ b/machines/neuromancer.nix @@ -22,25 +22,13 @@ Notes: ip = ip_pub; name = name; hostname = hostname; + interface = "en01"; }; in { imports = [ ./hardware/RM007.nix ]; - networking.hostName = name; - # this has to be defined for any physical servers - # vms are defined by teh vm host - networking = { - defaultGateway.interface = lib.mkForce "eno1"; - interfaces.eno1.ipv4.addresses = [ - { - address = ip_pub; - prefixLength = 26; - } - ]; - }; - deployment = { targetHost = hostname; targetPort = 22; diff --git a/machines/skynet.nix b/machines/skynet.nix index 720e9a3..546596e 100644 --- a/machines/skynet.nix +++ b/machines/skynet.nix @@ -23,6 +23,8 @@ Notes: Does not host offical sites ip = ip_pub; name = name; hostname = hostname; + interface = "eth1"; + cidr = 28; }; in { imports = [ diff --git a/machines/vendetta.nix b/machines/vendetta.nix index 7b89f84..faea1a5 100644 --- a/machines/vendetta.nix +++ b/machines/vendetta.nix @@ -22,14 +22,14 @@ Notes: Using the server that used to be called Earth ip = ip_pub; name = name; hostname = hostname; + # only required for physical servers + interface = "en01"; }; in { imports = [ ./hardware/RM002.nix ]; - networking.hostName = name; - deployment = { targetHost = ip_pub; targetPort = 22; @@ -38,18 +38,6 @@ in { tags = ["active-dns" "dns"]; }; - networking = { - # needs to have an address statically assigned - - defaultGateway.interface = lib.mkForce "eno1"; - interfaces.eno1.ipv4.addresses = [ - { - address = "193.1.99.120"; - prefixLength = 26; - } - ]; - }; - services.skynet = { host = host; backup.enable = true;