ipfs: added defaultMode, added norouting service

This commit is contained in:
Maximilian Güntner 2017-08-12 15:40:05 +02:00 committed by Franz Pletz
parent cb2f2aa563
commit 0f02879e01
No known key found for this signature in database
GPG Key ID: 846FDED7792617B4

View File

@ -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;
};
};
};
}