Summary Files Commits Branches @commit @diff @stats
path: root / modules / server
diff options
context:
space:
mode:
Commit4a93734a74aaefa2f85c9a5483d1668483209267 (patch)
Author
 Syndamia <kamen@syndamia.com>
2026-01-24 23:39:28 +0200
Committer
 Syndamia <kamen@syndamia.com>
2026-01-24 23:39:28 +0200
Files0f6c1caf2f0f13d56baeaedb4796f003490be7dd /modules/server
nix-4a93734a74aaefa2f85c9a5483d1668483209267.tar
nix-4a93734a74aaefa2f85c9a5483d1668483209267.tar.gz
nix-4a93734a74aaefa2f85c9a5483d1668483209267.zip
Parent705da9ba2e25fad5f680896f50307f3373d621e2 (diff)
feat(machines)!: Split duties between marduk and uttu
1 files changed, 62 insertions, 0 deletions
-rw-r--r--modules/server/srv.nix62
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);
+ };
+}