mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-25 08:23:09 +00:00
services: ipfs: add emptyRepo option, refactor
This commit is contained in:
parent
a652099c46
commit
a541f86f8b
@ -67,6 +67,14 @@ in
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
emptyRepo = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
description = ''
|
||||||
|
If set to true, the repo won't be initialized with help files
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
extraFlags = mkOption {
|
extraFlags = mkOption {
|
||||||
type = types.listOf types.str;
|
type = types.listOf types.str;
|
||||||
description = "Extra flags passed to the IPFS daemon";
|
description = "Extra flags passed to the IPFS daemon";
|
||||||
@ -103,16 +111,17 @@ in
|
|||||||
after = [ "network.target" "local-fs.target" ];
|
after = [ "network.target" "local-fs.target" ];
|
||||||
path = [ pkgs.ipfs pkgs.su pkgs.bash ];
|
path = [ pkgs.ipfs pkgs.su pkgs.bash ];
|
||||||
|
|
||||||
preStart =
|
preStart = ''
|
||||||
''
|
install -m 0755 -o ${cfg.user} -g ${cfg.group} -d ${cfg.dataDir}
|
||||||
install -m 0755 -o ${cfg.user} -g ${cfg.group} -d ${cfg.dataDir}
|
if [[ ! -d ${cfg.dataDir}/.ipfs ]]; then
|
||||||
if [[ ! -d ${cfg.dataDir}/.ipfs ]]; then
|
cd ${cfg.dataDir}
|
||||||
cd ${cfg.dataDir}
|
${pkgs.su}/bin/su -s ${pkgs.bash}/bin/sh ${cfg.user} -c \
|
||||||
${pkgs.su}/bin/su -s ${pkgs.bash}/bin/sh ${cfg.user} -c "${ipfs}/bin/ipfs init"
|
"${ipfs}/bin/ipfs init ${if cfg.emptyRepo then "-e" else ""}"
|
||||||
fi
|
fi
|
||||||
${pkgs.su}/bin/su -s ${pkgs.bash}/bin/sh ${cfg.user} -c "${ipfs}/bin/ipfs config Addresses.API ${cfg.apiAddress}"
|
${pkgs.su}/bin/su -s ${pkgs.bash}/bin/sh ${cfg.user} -c \
|
||||||
${pkgs.su}/bin/su -s ${pkgs.bash}/bin/sh ${cfg.user} -c "${ipfs}/bin/ipfs config Addresses.Gateway ${cfg.gatewayAddress}"
|
"${ipfs}/bin/ipfs --local config Addresses.API ${cfg.apiAddress} && \
|
||||||
'';
|
${ipfs}/bin/ipfs --local config Addresses.Gateway ${cfg.gatewayAddress}"
|
||||||
|
'';
|
||||||
|
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
ExecStart = "${ipfs}/bin/ipfs daemon ${ipfsFlags}";
|
ExecStart = "${ipfs}/bin/ipfs daemon ${ipfsFlags}";
|
||||||
|
Loading…
Reference in New Issue
Block a user