diff options
| Commit | 9f9f8c5287634540997107096ae4eca4f072bcca (patch) | |
|---|---|---|
| Author | 2026-01-27 20:34:52 +0200 | |
| Committer | 2026-01-27 20:35:58 +0200 | |
| Files | ea42312565a48ab001eddaad6ef42fb069fc97ef /modules/server | |
| nix-9f9f8c5287634540997107096ae4eca4f072bcca.tar nix-9f9f8c5287634540997107096ae4eca4f072bcca.tar.gz nix-9f9f8c5287634540997107096ae4eca4f072bcca.zip | ||
| Parent | c8b3a32097c3206b38b039cb578c090342bf865c (diff) | |
feat(modules/server): Add to srv module option sldsImport
1 files changed, 48 insertions, 5 deletions
| -rw-r--r-- | modules/server/srv.nix | 53 |
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)) + ]; }; } |
