diff options
| Commit | 4a93734a74aaefa2f85c9a5483d1668483209267 (patch) | |
|---|---|---|
| Author | 2026-01-24 23:39:28 +0200 | |
| Committer | 2026-01-24 23:39:28 +0200 | |
| Files | 0f6c1caf2f0f13d56baeaedb4796f003490be7dd /modules/server | |
| nix-4a93734a74aaefa2f85c9a5483d1668483209267.tar nix-4a93734a74aaefa2f85c9a5483d1668483209267.tar.gz nix-4a93734a74aaefa2f85c9a5483d1668483209267.zip | ||
| Parent | 705da9ba2e25fad5f680896f50307f3373d621e2 (diff) | |
feat(machines)!: Split duties between marduk and uttu
1 files changed, 62 insertions, 0 deletions
| -rw-r--r-- | modules/server/srv.nix | 62 |
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); + }; +} |
