mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-12-30 23:34:12 +03:00
ipfs: add autoMount option
This commit is contained in:
parent
0bb2d3112b
commit
a48a2c4f78
@ -7,7 +7,11 @@ let
|
|||||||
|
|
||||||
cfg = config.services.ipfs;
|
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
|
# 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
|
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
|
# 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 ]; } ''
|
wrapped = runCommand "ipfs" { buildInputs = [ makeWrapper ]; } ''
|
||||||
mkdir -p "$out/bin"
|
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
|
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 {
|
gatewayAddress = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "/ip4/127.0.0.1/tcp/8080";
|
default = "/ip4/127.0.0.1/tcp/8080";
|
||||||
@ -139,6 +151,10 @@ in
|
|||||||
fi
|
fi
|
||||||
${ipfs}/bin/ipfs --local config Addresses.API ${cfg.apiAddress}
|
${ipfs}/bin/ipfs --local config Addresses.API ${cfg.apiAddress}
|
||||||
${ipfs}/bin/ipfs --local config Addresses.Gateway ${cfg.gatewayAddress}
|
${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 = {
|
serviceConfig = {
|
||||||
|
Loading…
Reference in New Issue
Block a user