From 0f02879e010a1a091b00965ab9d31787f5fabc1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20G=C3=BCntner?= Date: Sat, 12 Aug 2017 15:40:05 +0200 Subject: [PATCH] ipfs: added defaultMode, added norouting service --- .../services/network-filesystems/ipfs.nix | 39 +++++++++++++++++-- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/nixos/modules/services/network-filesystems/ipfs.nix b/nixos/modules/services/network-filesystems/ipfs.nix index 10c1d751ac5..60822b5b547 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; + }; + }; + }; }