Skip to content

Commit

Permalink
ipfs: added defaultMode, added norouting service
Browse files Browse the repository at this point in the history
  • Loading branch information
mguentner authored and fpletz committed Aug 17, 2017
1 parent cb2f2aa commit 0f02879
Showing 1 changed file with 36 additions and 3 deletions.
39 changes: 36 additions & 3 deletions nixos/modules/services/network-filesystems/ipfs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
};
};

};
}

0 comments on commit 0f02879

Please sign in to comment.