summary refs log tree commit diff
path: root/nixos/modules/services/network-filesystems/ipfs.nix
diff options
context:
space:
mode:
authorEric Litak <elitak@gmail.com>2017-08-29 10:34:48 -0700
committerEric Litak <elitak@gmail.com>2017-08-30 08:17:34 -0700
commit5554ea55838f7b4fd3bf8f3efd7ef51180965eae (patch)
tree1189dc958f3d6807f1c1443fef22fa33327a414f /nixos/modules/services/network-filesystems/ipfs.nix
parentba976021af3b191263e86d4f1b8605d12ae56387 (diff)
downloadnixpkgs-5554ea55838f7b4fd3bf8f3efd7ef51180965eae.tar
nixpkgs-5554ea55838f7b4fd3bf8f3efd7ef51180965eae.tar.gz
nixpkgs-5554ea55838f7b4fd3bf8f3efd7ef51180965eae.tar.bz2
nixpkgs-5554ea55838f7b4fd3bf8f3efd7ef51180965eae.tar.lz
nixpkgs-5554ea55838f7b4fd3bf8f3efd7ef51180965eae.tar.xz
nixpkgs-5554ea55838f7b4fd3bf8f3efd7ef51180965eae.tar.zst
nixpkgs-5554ea55838f7b4fd3bf8f3efd7ef51180965eae.zip
ipfs: preStart configuration moved into daemon services
Diffstat (limited to 'nixos/modules/services/network-filesystems/ipfs.nix')
-rw-r--r--nixos/modules/services/network-filesystems/ipfs.nix40
1 files changed, 21 insertions, 19 deletions
diff --git a/nixos/modules/services/network-filesystems/ipfs.nix b/nixos/modules/services/network-filesystems/ipfs.nix
index d6840b0ea0d..34bb6770efd 100644
--- a/nixos/modules/services/network-filesystems/ipfs.nix
+++ b/nixos/modules/services/network-filesystems/ipfs.nix
@@ -36,6 +36,26 @@ let
 
   baseService = recursiveUpdate commonEnv {
     wants = [ "ipfs-init.service" ];
+    preStart = ''
+      ipfs --local config Addresses.API ${cfg.apiAddress}
+      ipfs --local config Addresses.Gateway ${cfg.gatewayAddress}
+    '' + optionalString cfg.autoMount ''
+      ipfs --local config Mounts.FuseAllowOther --json true
+      mkdir -p $(ipfs --local config Mounts.IPFS)
+      mkdir -p $(ipfs --local config Mounts.IPNS)
+    '' + 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 --local config --json "${concatStringsSep "." path}" "$value"
+            '')
+            cfg.extraConfig)
+        );
     serviceConfig = {
       ExecStart = "${wrapped}/bin/ipfs daemon ${ipfsFlags}";
       Restart = "on-failure";
@@ -188,25 +208,7 @@ in {
         if [[ ! -f ${cfg.dataDir}/config ]]; then
           ipfs init ${optionalString cfg.emptyRepo "-e"}
         fi
-        ipfs --local config Addresses.API ${cfg.apiAddress}
-        ipfs --local config Addresses.Gateway ${cfg.gatewayAddress}
-      '' + optionalString cfg.autoMount ''
-        ipfs --local config Mounts.FuseAllowOther --json true
-        mkdir -p $(ipfs --local config Mounts.IPFS)
-        mkdir -p $(ipfs --local config Mounts.IPNS)
-      '' + 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 --local config --json "${concatStringsSep "." path}" "$value"
-              '')
-              cfg.extraConfig)
-          );
+      '';
 
       serviceConfig = {
         Type = "oneshot";