summary refs log tree commit diff
path: root/nixos/modules/services/network-filesystems
diff options
context:
space:
mode:
authorschnusch <schnusch@users.noreply.github.com>2022-02-06 13:04:11 +0100
committerschnusch <schnusch@users.noreply.github.com>2022-02-06 21:42:56 +0100
commit97f809dc87f74ef51e4f0482328f7db617db91ef (patch)
tree929016ecb9659650dca4a302c69c56f51af2ad69 /nixos/modules/services/network-filesystems
parent25124556397ba17bfd70297000270de1e6523b0a (diff)
downloadnixpkgs-97f809dc87f74ef51e4f0482328f7db617db91ef.tar
nixpkgs-97f809dc87f74ef51e4f0482328f7db617db91ef.tar.gz
nixpkgs-97f809dc87f74ef51e4f0482328f7db617db91ef.tar.bz2
nixpkgs-97f809dc87f74ef51e4f0482328f7db617db91ef.tar.lz
nixpkgs-97f809dc87f74ef51e4f0482328f7db617db91ef.tar.xz
nixpkgs-97f809dc87f74ef51e4f0482328f7db617db91ef.tar.zst
nixpkgs-97f809dc87f74ef51e4f0482328f7db617db91ef.zip
nixos/ipfs: use ipfs config replace
Diffstat (limited to 'nixos/modules/services/network-filesystems')
-rw-r--r--nixos/modules/services/network-filesystems/ipfs.nix29
1 files changed, 11 insertions, 18 deletions
diff --git a/nixos/modules/services/network-filesystems/ipfs.nix b/nixos/modules/services/network-filesystems/ipfs.nix
index 5482b2aaf88..b311b91b4a0 100644
--- a/nixos/modules/services/network-filesystems/ipfs.nix
+++ b/nixos/modules/services/network-filesystems/ipfs.nix
@@ -260,24 +260,17 @@ in
         ipfs --offline config Mounts.IPNS ${cfg.ipnsMountDir}
       '' + optionalString cfg.autoMigrate ''
         ${pkgs.ipfs-migrator}/bin/fs-repo-migrations -y
-      '' + concatStringsSep "\n" (collect
-        isString
-        (mapAttrsRecursive
-          (path: value:
-            # Using heredoc below so that the value is never improperly quoted
-            ''
-              read value <<EOF
-              ${builtins.toJSON value}
-              EOF
-              ipfs --offline config --json "${concatStringsSep "." path}" "$value"
-            '')
-          ({
-            Addresses.API = cfg.apiAddress;
-            Addresses.Gateway = cfg.gatewayAddress;
-            Addresses.Swarm = cfg.swarmAddress;
-          } //
-          cfg.extraConfig))
-      );
+      '' + ''
+        ipfs --offline config show \
+          | ${pkgs.jq}/bin/jq '. * $extraConfig' --argjson extraConfig ${
+              escapeShellArg (builtins.toJSON ({
+                Addresses.API = cfg.apiAddress;
+                Addresses.Gateway = cfg.gatewayAddress;
+                Addresses.Swarm = cfg.swarmAddress;
+              } // cfg.extraConfig))
+            } \
+          | ipfs --offline config replace -
+      '';
       serviceConfig = {
         ExecStart = [ "" "${cfg.package}/bin/ipfs daemon ${ipfsFlags}" ];
         User = cfg.user;