{ config, lib, ... }: with lib; { options.srv = { static = mkOption { type = types.nullOr (types.submodule { options = { ip = mkOption { type = types.str; example = "10.0.0.0"; }; prefixLength = mkOption { type = types.ints.between 0 32; default = 24; example = 32; }; interface = mkOption { type = types.str; example = "ens3"; }; }; }); default = null; }; tld = mkOption { type = types.nullOr types.str; default = null; example = "local"; }; slds = mkOption { type = types.listOf types.str; default = []; }; }; config = let netinterfaces = config: { ${config.srv.static.interface}.ipv4.addresses = [{ address = config.srv.static.ip; prefixLength = config.srv.static.prefixLength; }]; }; in { networking.interfaces = mkIf (config.srv.static != null) (netinterfaces config); virtualisation.vmVariant.networking.interfaces = mkIf (config.srv.static != null) (lib.mkVMOverride (netinterfaces (lib.recursiveUpdate config { srv.static.interface = "eth0"; }))); services.dnsmasq.settings.address = mkIf (config.srv.static != null && config.srv.tld != null) (builtins.map (sld: "/${sld}.${config.srv.tld}/${config.srv.static.ip}") config.srv.slds); }; }