diff options
author | Franz Pletz <fpletz@fnordicwalking.de> | 2017-01-15 18:16:00 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-15 18:16:00 +0100 |
commit | 30645560cd0eb9b1e9bb5f5894f90edc4dea67b3 (patch) | |
tree | 39c4a76358d77669b7d2cffd26e288066eec40dc /nixos | |
parent | 3eafa26d75d0401d2484fbcba731a31751c82ad6 (diff) | |
parent | a541f86f8b6095eaa4ee576d2655a0fe8dc9dad9 (diff) |
Merge pull request #21880 from mguentner/ipfs_empty_repo
services: ipfs: add emptyRepo option, refactor
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/modules/services/network-filesystems/ipfs.nix | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/nixos/modules/services/network-filesystems/ipfs.nix b/nixos/modules/services/network-filesystems/ipfs.nix index 104b5b92620ea..d43147a16f312 100644 --- a/nixos/modules/services/network-filesystems/ipfs.nix +++ b/nixos/modules/services/network-filesystems/ipfs.nix @@ -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 { type = types.listOf types.str; description = "Extra flags passed to the IPFS daemon"; @@ -103,16 +111,17 @@ in after = [ "network.target" "local-fs.target" ]; path = [ pkgs.ipfs pkgs.su pkgs.bash ]; - preStart = - '' - install -m 0755 -o ${cfg.user} -g ${cfg.group} -d ${cfg.dataDir} - if [[ ! -d ${cfg.dataDir}/.ipfs ]]; then - cd ${cfg.dataDir} - ${pkgs.su}/bin/su -s ${pkgs.bash}/bin/sh ${cfg.user} -c "${ipfs}/bin/ipfs init" - 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 "${ipfs}/bin/ipfs config Addresses.Gateway ${cfg.gatewayAddress}" - ''; + preStart = '' + install -m 0755 -o ${cfg.user} -g ${cfg.group} -d ${cfg.dataDir} + if [[ ! -d ${cfg.dataDir}/.ipfs ]]; then + cd ${cfg.dataDir} + ${pkgs.su}/bin/su -s ${pkgs.bash}/bin/sh ${cfg.user} -c \ + "${ipfs}/bin/ipfs init ${if cfg.emptyRepo then "-e" else ""}" + fi + ${pkgs.su}/bin/su -s ${pkgs.bash}/bin/sh ${cfg.user} -c \ + "${ipfs}/bin/ipfs --local config Addresses.API ${cfg.apiAddress} && \ + ${ipfs}/bin/ipfs --local config Addresses.Gateway ${cfg.gatewayAddress}" + ''; serviceConfig = { ExecStart = "${ipfs}/bin/ipfs daemon ${ipfsFlags}"; |