From 9f9f8c5287634540997107096ae4eca4f072bcca Mon Sep 17 00:00:00 2001 From: Syndamia Date: Tue, 27 Jan 2026 20:34:52 +0200 Subject: feat(modules/server): Add to srv module option sldsImport --- modules/server/srv.nix | 53 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 48 insertions(+), 5 deletions(-) (limited to 'modules/server') diff --git a/modules/server/srv.nix b/modules/server/srv.nix index 0ec63bd..8594c0a 100644 --- a/modules/server/srv.nix +++ b/modules/server/srv.nix @@ -29,6 +29,10 @@ type = types.listOf types.str; default = []; }; + sldsImport = mkOption { + type = types.listOf types.path; + default = []; + }; }; config = let @@ -88,10 +92,49 @@ 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); + services.dnsmasq.settings.address = mkMerge [ + (mkIf + (config.srv.static != null && config.srv.tld != null) + (builtins.map + (sld: "/${sld}.${config.srv.tld}/${config.srv.static.ip}") + config.srv.slds)) + + (mkIf + (config.srv.sldsImport != []) + (let + importModule = mpath: + let + module = import mpath; + in + if builtins.isFunction module + then module { config = {}; lib = {}; pkgs = {}; } + else module; + + importSLDs = mpath: + let + module = importModule mpath; + in + (module.srv.slds or []) ++ + (builtins.foldl' + (acc: x: + acc ++ importSLDs x) + [] + (module.imports or [])); + + sldConfigs = builtins.map + (mpath: + let + # TODO: ugly and hard-coded, must be fixed some day + m = importModule mpath; + inherit (m.srv) tld; + inherit (m.srv.static) ip; + in + builtins.map + (sld: "/${sld}.${tld}/${ip}") + (importSLDs mpath)) + config.srv.sldsImport; + in + lib.flatten sldConfigs)) + ]; }; } -- cgit v1.3.1-23-gd82d