@@ -44,9 +44,7 @@ let
4444 parseModules = x:
4545 x // { connectTo = mapAttrs (name: value: { inherit (value) password publicKey; }) x.connectTo; };
4646
47− # would be nice to merge 'cfg' with a //,
48− # but the json nesting is wacky.
49− cjdrouteConf = builtins.toJSON ( {
47+ cjdrouteConf = builtins.toJSON ( recursiveUpdate {
5048 admin = {
5149 bind = cfg.admin.bind;
5250 password = "@CJDNS_ADMIN_PASSWORD@";
@@ -71,7 +69,7 @@ let
7169
7270 security = [ { exemptAngel = 1; setuser = "nobody"; } ];
7371
74− });
72+ } cfg.extraConfig);
7573
7674in
7775
@@ -91,6 +89,16 @@ in
9189 '';
9290 };
9391
92+ extraConfig = mkOption {
93+ type = types.attrs;
94+ default = {};
95+ example = { router.interface.tunDevice = "tun10"; };
96+ description = ''
97+ Extra configuration, given as attrs, that will be merged recursively
98+ with the rest of the JSON generated by this module, at the root node.
99+ '';
100+ };
101+
94102 confFile = mkOption {
95103 type = types.nullOr types.path;
96104 default = null;
@@ -246,7 +254,10 @@ in
246254 if cfg.confFile != null then "${pkg}/bin/cjdroute < ${cfg.confFile}" else
247255 ''
248256 source /etc/cjdns.keys
249− echo '${cjdrouteConf}' | sed \
257+ (cat <<'EOF'
258+ ${cjdrouteConf}
259+ EOF
260+ ) | sed \
250261 -e "s/@CJDNS_ADMIN_PASSWORD@/$CJDNS_ADMIN_PASSWORD/g" \
251262 -e "s/@CJDNS_PRIVATE_KEY@/$CJDNS_PRIVATE_KEY/g" \
252263 | ${pkg}/bin/cjdroute