diff --git a/nixos/roles/vmNetwork.nix b/nixos/roles/vmNetwork.nix index ff4c3ef..c378af8 100644 --- a/nixos/roles/vmNetwork.nix +++ b/nixos/roles/vmNetwork.nix @@ -6,9 +6,7 @@ inherit (lib) lists mapAttrsToList; inherit (lib.attrsets) foldAttrs concatMapAttrs; inherit (lib.asserts) assertMsg; - inherit (lib.lists) filter last init; - inherit (lib.strings) splitString toInt concatStringsSep; - inherit (builtins) elem toString; + inherit (builtins) elem; hostmap = import ./hostmap.nix; myhostName = config.networking.hostName; # To turn the hostmap around suitable for networking.hosts the following simple code almost works @@ -21,26 +19,14 @@ if (elem myhostName hosts) # nixos maps the hostname to the loopback 127.0.0.2 by default, so we exclude it here. # there is also a default localhost to 127.0.0.1 in place - then {"127.0.0.1" = filter (x: x != myhostName) hosts;} + then {"127.0.0.1" = lists.filter (x: x != myhostName) hosts;} else {${ip} = hosts;}) globalhosts; myIp = assert (assertMsg (hostmap ? ${myhostName}.ipv4) "${myhostName} has no ip configured in nixos/roles/hostmap.nix"); hostmap.${myhostName}.ipv4; in { - networking = { - hosts = myhosts; - interfaces.enX0.ipv4.addresses = [ - { - address = myIp; - prefixLength = 16; - } - ]; - defaultGateway = let - addr = splitString "." myIp; - addrInit = init addr; - addrLastInt = toString (toInt (last addr) + 127); - in - concatStringsSep "." (addrInit ++ [addrLastInt]); - # https://www.hrz.tu-darmstadt.de/services/it_services/nameserver_dns/index.de.jsp - nameservers = ["130.83.22.63" "130.83.22.60" "130.83.56.60"]; - }; + imports = [ + ../modules/vmNetwork.nix + ]; + networking.hosts = myhosts; + vmNetwork.ipv4 = myIp; }