Summary Files Commits Branches @commit @diff @stats
path: root / modules / server
diff options
context:
space:
mode:
1 files changed, 48 insertions, 5 deletions
-rw-r--r--modules/server/srv.nix53
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))
+ ];
};
}