diff options
author | Eric Litak <elitak@gmail.com> | 2017-08-08 01:52:08 -0700 |
---|---|---|
committer | Eric Litak <elitak@gmail.com> | 2017-08-30 08:17:34 -0700 |
commit | a48a2c4f788003a9e19dd63730732f82e835ba0f (patch) | |
tree | 83262ffd9139d4b487b4d32143704328eac9c3ec /nixos/modules/services/network-filesystems | |
parent | 0bb2d3112b259940df18ec6c0203bb01234f4e48 (diff) | |
download | nixlib-a48a2c4f788003a9e19dd63730732f82e835ba0f.tar nixlib-a48a2c4f788003a9e19dd63730732f82e835ba0f.tar.gz nixlib-a48a2c4f788003a9e19dd63730732f82e835ba0f.tar.bz2 nixlib-a48a2c4f788003a9e19dd63730732f82e835ba0f.tar.lz nixlib-a48a2c4f788003a9e19dd63730732f82e835ba0f.tar.xz nixlib-a48a2c4f788003a9e19dd63730732f82e835ba0f.tar.zst nixlib-a48a2c4f788003a9e19dd63730732f82e835ba0f.zip |
ipfs: add autoMount option
Diffstat (limited to 'nixos/modules/services/network-filesystems')
-rw-r--r-- | nixos/modules/services/network-filesystems/ipfs.nix | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/nixos/modules/services/network-filesystems/ipfs.nix b/nixos/modules/services/network-filesystems/ipfs.nix index 60822b5b547f..74711a10abb2 100644 --- a/nixos/modules/services/network-filesystems/ipfs.nix +++ b/nixos/modules/services/network-filesystems/ipfs.nix @@ -7,7 +7,11 @@ let cfg = config.services.ipfs; - ipfsFlags = ''${if cfg.autoMigrate then "--migrate" else ""} ${if cfg.enableGC then "--enable-gc" else ""} ${toString cfg.extraFlags}''; + ipfsFlags = toString ([ + (optionalString cfg.autoMount "--mount") + (optionalString cfg.autoMigrate "--migrate") + (optionalString cfg.enableGC "--enable-gc") + ] ++ cfg.extraFlags); # Before Version 17.09, ipfs would always use "/var/lib/ipfs/.ipfs" as it's dataDir defaultDataDir = if versionAtLeast config.system.stateVersion "17.09" then @@ -17,7 +21,9 @@ let # Wrapping the ipfs binary with the environment variable IPFS_PATH set to dataDir because we can't set it in the user environment wrapped = runCommand "ipfs" { buildInputs = [ makeWrapper ]; } '' mkdir -p "$out/bin" - makeWrapper "${ipfs}/bin/ipfs" "$out/bin/ipfs" --set IPFS_PATH ${cfg.dataDir} + makeWrapper "${ipfs}/bin/ipfs" "$out/bin/ipfs" \ + --set IPFS_PATH ${cfg.dataDir} \ + --prefix PATH : /run/wrappers/bin ''; in @@ -63,6 +69,12 @@ in ''; }; + autoMount = mkOption { + type = types.bool; + default = false; + description = "Whether IPFS should try to mount /ipfs and /ipns at startup."; + }; + gatewayAddress = mkOption { type = types.str; default = "/ip4/127.0.0.1/tcp/8080"; @@ -133,12 +145,16 @@ in preStart = '' install -m 0755 -o ${cfg.user} -g ${cfg.group} -d ${cfg.dataDir} ''; - script = '' + script = '' if [[ ! -f ${cfg.dataDir}/config ]]; then ${ipfs}/bin/ipfs init ${optionalString cfg.emptyRepo "-e"} fi ${ipfs}/bin/ipfs --local config Addresses.API ${cfg.apiAddress} ${ipfs}/bin/ipfs --local config Addresses.Gateway ${cfg.gatewayAddress} + '' + optionalString cfg.autoMount '' + ${ipfs}/bin/ipfs --local config Mounts.FuseAllowOther --json true + mkdir -p $(${ipfs}/bin/ipfs --local config Mounts.IPFS) + mkdir -p $(${ipfs}/bin/ipfs --local config Mounts.IPNS) ''; serviceConfig = { |