modules/ipfs-cluster: make package configurable

This commit is contained in:
Max Headroom 2022-10-19 23:08:11 +02:00
parent 2c8f38378b
commit 0c71c520fb

View file

@ -20,6 +20,12 @@ in {
enable = mkEnableOption enable = mkEnableOption
"Pinset orchestration for IPFS - requires ipfs daemon to be useful"; "Pinset orchestration for IPFS - requires ipfs daemon to be useful";
package = mkOption {
type = types.package;
default = pkgs.ipfs-cluster;
description = "ipfs-cluster package";
};
user = mkOption { user = mkOption {
type = types.str; type = types.str;
default = "ipfs"; default = "ipfs";
@ -75,14 +81,14 @@ in {
###### implementation ###### implementation
config = mkIf cfg.enable { config = mkIf cfg.enable {
environment.systemPackages = [ pkgs.ipfs-cluster ]; environment.systemPackages = [ cfg.package ];
systemd.tmpfiles.rules = systemd.tmpfiles.rules =
[ "d '${cfg.dataDir}' - ${cfg.user} ${cfg.group} - -" ]; [ "d '${cfg.dataDir}' - ${cfg.user} ${cfg.group} - -" ];
systemd.services.ipfs-cluster-init = { systemd.services.ipfs-cluster-init = {
path = [ "/run/wrappers" pkgs.ipfs-cluster ]; path = [ "/run/wrappers" cfg.package ];
environment.IPFS_CLUSTER_PATH = cfg.dataDir; environment.IPFS_CLUSTER_PATH = cfg.dataDir;
wantedBy = [ "default.target" ]; wantedBy = [ "default.target" ];
@ -90,7 +96,7 @@ in {
# "" clears exec list (man systemd.service -> execStart) # "" clears exec list (man systemd.service -> execStart)
ExecStart = [ ExecStart = [
"" ""
"${pkgs.ipfs-cluster}/bin/ipfs-cluster-service init --consensus ${cfg.consensus} ${initFlags}" "${cfg.package}/bin/ipfs-cluster-service init --consensus ${cfg.consensus} ${initFlags}"
]; ];
Type = "oneshot"; Type = "oneshot";
RemainAfterExit = true; RemainAfterExit = true;
@ -111,7 +117,7 @@ in {
serviceConfig = { serviceConfig = {
ExecStart = ExecStart =
[ "" "${pkgs.ipfs-cluster}/bin/ipfs-cluster-service daemon" ]; [ "" "${cfg.package}/bin/ipfs-cluster-service daemon" ];
User = cfg.user; User = cfg.user;
Group = cfg.group; Group = cfg.group;
}; };