summary refs log tree commit diff
path: root/nixos/modules
diff options
context:
space:
mode:
authorMaximilian Güntner <code@sourcediver.org>2017-08-12 15:40:05 +0200
committerFranz Pletz <fpletz@fnordicwalking.de>2017-08-17 03:30:57 +0200
commit0f02879e010a1a091b00965ab9d31787f5fabc1e (patch)
tree695c1f156e711160afd97d59e281e926fd9dcc66 /nixos/modules
parentcb2f2aa563a5be0eca70d3a16a9351a7d419438f (diff)
downloadnixlib-0f02879e010a1a091b00965ab9d31787f5fabc1e.tar
nixlib-0f02879e010a1a091b00965ab9d31787f5fabc1e.tar.gz
nixlib-0f02879e010a1a091b00965ab9d31787f5fabc1e.tar.bz2
nixlib-0f02879e010a1a091b00965ab9d31787f5fabc1e.tar.lz
nixlib-0f02879e010a1a091b00965ab9d31787f5fabc1e.tar.xz
nixlib-0f02879e010a1a091b00965ab9d31787f5fabc1e.tar.zst
nixlib-0f02879e010a1a091b00965ab9d31787f5fabc1e.zip
ipfs: added defaultMode, added norouting service
Diffstat (limited to 'nixos/modules')
-rw-r--r--nixos/modules/services/network-filesystems/ipfs.nix39
1 files changed, 36 insertions, 3 deletions
diff --git a/nixos/modules/services/network-filesystems/ipfs.nix b/nixos/modules/services/network-filesystems/ipfs.nix
index 10c1d751ac5d..60822b5b547f 100644
--- a/nixos/modules/services/network-filesystems/ipfs.nix
+++ b/nixos/modules/services/network-filesystems/ipfs.nix
@@ -49,6 +49,12 @@ in
         description = "The data dir for IPFS";
       };
 
+      defaultMode = mkOption {
+        description = "systemd service that is enabled by default";
+        type = types.enum [ "online" "offline" "norouting" ];
+        default = "online";
+      };
+
       autoMigrate = mkOption {
         type = types.bool;
         default = false;
@@ -147,10 +153,11 @@ in
     systemd.services.ipfs = {
       description = "IPFS Daemon";
 
-      wantedBy = [ "multi-user.target" ];
+      wantedBy = mkIf (cfg.defaultMode == "online") [ "multi-user.target" ];
+
       after = [ "network.target" "local-fs.target" "ipfs-init.service" ];
 
-      conflicts = [ "ipfs-offline.service" ];
+      conflicts = [ "ipfs-offline.service" "ipfs-norouting.service"];
       wants = [ "ipfs-init.service" ];
 
       environment.IPFS_PATH = cfg.dataDir;
@@ -169,9 +176,11 @@ in
     systemd.services.ipfs-offline = {
       description = "IPFS Daemon (offline mode)";
 
+      wantedBy = mkIf (cfg.defaultMode == "offline") [ "multi-user.target" ];
+
       after = [ "local-fs.target" "ipfs-init.service" ];
 
-      conflicts = [ "ipfs.service" ];
+      conflicts = [ "ipfs.service" "ipfs-norouting.service"];
       wants = [ "ipfs-init.service" ];
 
       environment.IPFS_PATH = cfg.dataDir;
@@ -186,5 +195,29 @@ in
         RestartSec = 1;
       };
     };
+
+    systemd.services.ipfs-norouting = {
+      description = "IPFS Daemon (no routing mode)";
+
+      wantedBy = mkIf (cfg.defaultMode == "norouting") [ "multi-user.target" ];
+
+      after = [ "local-fs.target" "ipfs-init.service" ];
+
+      conflicts = [ "ipfs.service" "ipfs-offline.service"];
+      wants = [ "ipfs-init.service" ];
+
+      environment.IPFS_PATH = cfg.dataDir;
+
+      path  = [ pkgs.ipfs ];
+
+      serviceConfig = {
+        ExecStart = "${ipfs}/bin/ipfs daemon ${ipfsFlags} --routing=none";
+        User = cfg.user;
+        Group = cfg.group;
+        Restart = "on-failure";
+        RestartSec = 1;
+      };
+    };
+
   };
 }