{ lib, config, ... }: let inherit (lib) mkOption types last init ; inherit (lib.strings) splitString concatStringsSep toInt ; cfg = config.vmNetwork; in { imports = []; options.vmNetwork = { ipv4 = mkOption { type = types.str; description = "the ipv4 adress of this machine"; }; }; config = { networking = { interfaces.enX0.ipv4.addresses = [ { address = cfg.ipv4; prefixLength = 16; } ]; defaultGateway = let addr = splitString "." cfg.ipv4; addrInit = init addr; addrLastInt = builtins.toString (toInt (last addr) + 127); in concatStringsSep "." (addrInit ++ [addrLastInt]); nameservers = ["130.83.2.22" "130.83.56.60" "130.83.22.60" "130.82.22.63"]; }; }; }