about summary refs log tree commit diff
path: root/nixos/modules/services/networking/cjdns.nix
diff options
context:
space:
mode:
authorEric Litak <elitak@gmail.com>2019-08-18 09:47:56 -0700
committerMarek Mahut <marek.mahut@gmail.com>2019-08-18 18:47:56 +0200
commitccf35570158791d1f341212c3d7d6bc549e5e4d4 (patch)
tree1ac44f6d5dd0295f5b41eef8382ef4bc6afdc28b /nixos/modules/services/networking/cjdns.nix
parente6fb350cf646ea8a417cbbf9ea0d59ee17c6ea01 (diff)
downloadnixlib-ccf35570158791d1f341212c3d7d6bc549e5e4d4.tar
nixlib-ccf35570158791d1f341212c3d7d6bc549e5e4d4.tar.gz
nixlib-ccf35570158791d1f341212c3d7d6bc549e5e4d4.tar.bz2
nixlib-ccf35570158791d1f341212c3d7d6bc549e5e4d4.tar.lz
nixlib-ccf35570158791d1f341212c3d7d6bc549e5e4d4.tar.xz
nixlib-ccf35570158791d1f341212c3d7d6bc549e5e4d4.tar.zst
nixlib-ccf35570158791d1f341212c3d7d6bc549e5e4d4.zip
nixos/cjdns: add extraConfig option (#53502)
Diffstat (limited to 'nixos/modules/services/networking/cjdns.nix')
-rw-r--r--nixos/modules/services/networking/cjdns.nix21
1 files changed, 16 insertions, 5 deletions
diff --git a/nixos/modules/services/networking/cjdns.nix b/nixos/modules/services/networking/cjdns.nix
index c40962f4aa82..3fb85b16cbe2 100644
--- a/nixos/modules/services/networking/cjdns.nix
+++ b/nixos/modules/services/networking/cjdns.nix
@@ -44,9 +44,7 @@ let
   parseModules = x:
     x // { connectTo = mapAttrs (name: value: { inherit (value) password publicKey; }) x.connectTo; };
 
-  # would be nice to  merge 'cfg' with a //,
-  # but the json nesting is wacky.
-  cjdrouteConf = builtins.toJSON ( {
+  cjdrouteConf = builtins.toJSON ( recursiveUpdate {
     admin = {
       bind = cfg.admin.bind;
       password = "@CJDNS_ADMIN_PASSWORD@";
@@ -71,7 +69,7 @@ let
 
     security = [ { exemptAngel = 1; setuser = "nobody"; } ];
 
-  });
+  } cfg.extraConfig);
 
 in
 
@@ -91,6 +89,16 @@ in
         '';
       };
 
+      extraConfig = mkOption {
+        type = types.attrs;
+        default = {};
+        example = { router.interface.tunDevice = "tun10"; };
+        description = ''
+          Extra configuration, given as attrs, that will be merged recursively
+          with the rest of the JSON generated by this module, at the root node.
+        '';
+      };
+
       confFile = mkOption {
         type = types.nullOr types.path;
         default = null;
@@ -246,7 +254,10 @@ in
         if cfg.confFile != null then "${pkg}/bin/cjdroute < ${cfg.confFile}" else
           ''
             source /etc/cjdns.keys
-            echo '${cjdrouteConf}' | sed \
+            (cat <<'EOF'
+            ${cjdrouteConf}
+            EOF
+            ) | sed \
                 -e "s/@CJDNS_ADMIN_PASSWORD@/$CJDNS_ADMIN_PASSWORD/g" \
                 -e "s/@CJDNS_PRIVATE_KEY@/$CJDNS_PRIVATE_KEY/g" \
                 | ${pkg}/bin/cjdroute