From 4a93734a74aaefa2f85c9a5483d1668483209267 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sat, 24 Jan 2026 23:39:28 +0200 Subject: feat(machines)!: Split duties between marduk and uttu --- modules/server/srv.nix | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 modules/server/srv.nix (limited to 'modules/server') diff --git a/modules/server/srv.nix b/modules/server/srv.nix new file mode 100644 index 0000000..7701ee5 --- /dev/null +++ b/modules/server/srv.nix @@ -0,0 +1,62 @@ +{ 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); + }; +} -- cgit v1.3.1-23-gd82d