modules/ipfs-cluster: manage service config
This commit is contained in:
parent
d86429d59e
commit
e5d56e7073
1 changed files with 16 additions and 0 deletions
|
@ -9,6 +9,8 @@ let
|
||||||
(optionalString (cfg.initPeers != [ ]) "--peers")
|
(optionalString (cfg.initPeers != [ ]) "--peers")
|
||||||
(lib.strings.concatStringsSep "," cfg.initPeers)
|
(lib.strings.concatStringsSep "," cfg.initPeers)
|
||||||
];
|
];
|
||||||
|
|
||||||
|
serviceJson = builtins.toFile "ipfs-cluster-service.json" (builtins.toJSON cfg.settings);
|
||||||
in {
|
in {
|
||||||
|
|
||||||
###### interface
|
###### interface
|
||||||
|
@ -75,6 +77,12 @@ in {
|
||||||
A secret in the correct format can also be generated by: openssl rand -hex 32
|
A secret in the correct format can also be generated by: openssl rand -hex 32
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
settings = mkOption {
|
||||||
|
type = types.attrs;
|
||||||
|
default = {};
|
||||||
|
description = "Configuration to be merged into service.json";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -115,7 +123,15 @@ in {
|
||||||
wants = [ "ipfs-cluster-init.service" ];
|
wants = [ "ipfs-cluster-init.service" ];
|
||||||
after = [ "ipfs-cluster-init.service" ];
|
after = [ "ipfs-cluster-init.service" ];
|
||||||
|
|
||||||
|
preStart = ''
|
||||||
|
${pkgs.jq}/bin/jq --slurp '.[0] * .[1]' '${cfg.dataDir}/service.json' ${serviceJson} \
|
||||||
|
| install -D -m 600 -o '${cfg.user}' -g '${cfg.group}' /dev/stdin '${cfg.dataDir}/.service.json.new'
|
||||||
|
mv '${cfg.dataDir}/.service.json.new' '${cfg.dataDir}/service.json'
|
||||||
|
'';
|
||||||
|
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
|
Type = "notify";
|
||||||
|
RuntimeDirectory = "ipfs-cluster";
|
||||||
ExecStart =
|
ExecStart =
|
||||||
[ "" "${cfg.package}/bin/ipfs-cluster-service daemon" ];
|
[ "" "${cfg.package}/bin/ipfs-cluster-service daemon" ];
|
||||||
User = cfg.user;
|
User = cfg.user;
|
||||||
|
|
Loading…
Reference in a new issue