summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorFranz Pletz <fpletz@fnordicwalking.de>2017-09-18 13:26:39 +0200
committerGitHub <noreply@github.com>2017-09-18 13:26:39 +0200
commitdecaa2e7bf88b27fbebeda72e69c032533afb0a8 (patch)
tree9accbbbc5037fbb65c28a9c43070e6526052dec3 /nixos
parent839e3c76662fafb0f16c77d1efcdb67197e57a03 (diff)
parent44475cae27d7f39355d7a8fd65b52d0ba42b0174 (diff)
downloadnixlib-decaa2e7bf88b27fbebeda72e69c032533afb0a8.tar
nixlib-decaa2e7bf88b27fbebeda72e69c032533afb0a8.tar.gz
nixlib-decaa2e7bf88b27fbebeda72e69c032533afb0a8.tar.bz2
nixlib-decaa2e7bf88b27fbebeda72e69c032533afb0a8.tar.lz
nixlib-decaa2e7bf88b27fbebeda72e69c032533afb0a8.tar.xz
nixlib-decaa2e7bf88b27fbebeda72e69c032533afb0a8.tar.zst
nixlib-decaa2e7bf88b27fbebeda72e69c032533afb0a8.zip
Merge pull request #29133 from elitak/ipfs
ipfs: workaround for upstream bug; other small fixes
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/services/network-filesystems/ipfs.nix52
-rw-r--r--nixos/tests/ipfs.nix6
2 files changed, 26 insertions, 32 deletions
diff --git a/nixos/modules/services/network-filesystems/ipfs.nix b/nixos/modules/services/network-filesystems/ipfs.nix
index cd320c5c4620..36e5efecf431 100644
--- a/nixos/modules/services/network-filesystems/ipfs.nix
+++ b/nixos/modules/services/network-filesystems/ipfs.nix
@@ -6,7 +6,7 @@ let
   cfg = config.services.ipfs;
 
   ipfsFlags = toString ([
-    #(optionalString  cfg.autoMount                   "--mount")
+    (optionalString  cfg.autoMount                   "--mount")
     (optionalString  cfg.autoMigrate                 "--migrate")
     (optionalString  cfg.enableGC                    "--enable-gc")
     (optionalString (cfg.serviceFdlimit != null)     "--manage-fdlimit=false")
@@ -37,9 +37,10 @@ let
   baseService = recursiveUpdate commonEnv {
     wants = [ "ipfs-init.service" ];
     preStart = ''
+      ipfs repo fsck # workaround for BUG #4212 (https://github.com/ipfs/go-ipfs/issues/4214)
       ipfs --local config Addresses.API ${cfg.apiAddress}
       ipfs --local config Addresses.Gateway ${cfg.gatewayAddress}
-    '' + optionalString false/*cfg.autoMount*/ ''
+    '' + optionalString cfg.autoMount ''
       ipfs --local config Mounts.FuseAllowOther --json true
       ipfs --local config Mounts.IPFS ${cfg.ipfsMountDir}
       ipfs --local config Mounts.IPNS ${cfg.ipnsMountDir}
@@ -91,24 +92,22 @@ in {
       };
 
       defaultMode = mkOption {
-        description = "systemd service that is enabled by default";
         type = types.enum [ "online" "offline" "norouting" ];
         default = "online";
+        description = "systemd service that is enabled by default";
       };
 
       autoMigrate = mkOption {
         type = types.bool;
         default = false;
-        description = ''
-          Whether IPFS should try to migrate the file system automatically.
-        '';
+        description = "Whether IPFS should try to migrate the file system automatically";
       };
 
-      #autoMount = mkOption {
-      #  type = types.bool;
-      #  default = false;
-      #  description = "Whether IPFS should try to mount /ipfs and /ipns at startup.";
-      #};
+      autoMount = mkOption {
+        type = types.bool;
+        default = false;
+        description = "Whether IPFS should try to mount /ipfs and /ipns at startup.";
+      };
 
       ipfsMountDir = mkOption {
         type = types.str;
@@ -137,26 +136,22 @@ in {
       enableGC = mkOption {
         type = types.bool;
         default = false;
-        description = ''
-          Whether to enable automatic garbage collection.
-        '';
+        description = "Whether to enable automatic garbage collection";
       };
 
       emptyRepo = mkOption {
         type = types.bool;
         default = false;
-        description = ''
-          If set to true, the repo won't be initialized with help files
-        '';
+        description = "If set to true, the repo won't be initialized with help files";
       };
 
       extraConfig = mkOption {
         type = types.attrs;
-        description = toString [
-          "Attrset of daemon configuration to set using `ipfs config`, every time the daemon starts."
-          "These are applied last, so may override configuration set by other options in this module."
-          "Keep in mind that this configuration is stateful; i.e., unsetting anything in here does not reset the value to the default!"
-        ];
+        description = ''
+          Attrset of daemon configuration to set using <command>ipfs config</command>, every time the daemon starts.
+          These are applied last, so may override configuration set by other options in this module.
+          Keep in mind that this configuration is stateful; i.e., unsetting anything in here does not reset the value to the default!
+        '';
         default = {};
         example = {
           Datastore.StorageMax = "100GB";
@@ -179,10 +174,8 @@ in {
       serviceFdlimit = mkOption {
         type = types.nullOr types.int;
         default = null;
-        description = ''
-          The fdlimit for the IPFS systemd unit or `null` to have the daemon attempt to manage it.
-        '';
-        example = 256*1024;
+        description = "The fdlimit for the IPFS systemd unit or <literal>null</literal> to have the daemon attempt to manage it";
+        example = 64*1024;
       };
 
     };
@@ -192,6 +185,9 @@ in {
 
   config = mkIf cfg.enable {
     environment.systemPackages = [ wrapped ];
+    environment.etc."fuse.conf" = mkIf cfg.autoMount { text = ''
+      user_allow_other
+    ''; };
 
     users.extraUsers = mkIf (cfg.user == "ipfs") {
       ipfs = {
@@ -211,11 +207,11 @@ in {
       description = "IPFS Initializer";
 
       after = [ "local-fs.target" ];
-      before = [ "ipfs.service" "ipfs-offline.service" ];
+      before = [ "ipfs.service" "ipfs-offline.service" "ipfs-norouting.service" ];
 
       preStart = ''
         install -m 0755 -o ${cfg.user} -g ${cfg.group} -d ${cfg.dataDir}
-      '' + optionalString false/*cfg.autoMount*/ ''
+      '' + optionalString cfg.autoMount ''
         install -m 0755 -o ${cfg.user} -g ${cfg.group} -d ${cfg.ipfsMountDir}
         install -m 0755 -o ${cfg.user} -g ${cfg.group} -d ${cfg.ipnsMountDir}
       '';
diff --git a/nixos/tests/ipfs.nix b/nixos/tests/ipfs.nix
index a93f8f175c55..c6bc61545245 100644
--- a/nixos/tests/ipfs.nix
+++ b/nixos/tests/ipfs.nix
@@ -23,8 +23,7 @@ import ./make-test.nix ({ pkgs, ...} : {
         services.ipfs = {
           enable = true;
           defaultMode = "norouting";
-          # not yet. See #28621
-          #autoMount = true;
+          autoMount = true;
         };
         networking.firewall.allowedTCPPorts = [ 4001 ];
       };
@@ -51,7 +50,6 @@ import ./make-test.nix ({ pkgs, ...} : {
 
     $getter->mustSucceed("ipfs --api /ip4/127.0.0.1/tcp/5001 swarm connect /ip4/$addrIp/tcp/4001/ipfs/$addrId");
     $getter->mustSucceed("[ -n \"\$(ipfs --api /ip4/127.0.0.1/tcp/5001 cat /ipfs/$ipfsHash | grep fnord)\" ]");
-    # not yet. See #28621
-    # $getter->mustSucceed("[ -n \"$(cat /ipfs/$ipfsHash | grep fnord)\" ]");
+    $getter->mustSucceed("[ -n \"$(cat /ipfs/$ipfsHash | grep fnord)\" ]");
     '';
 })