Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use NXF_HOME env var for nextflow home directory, if set #800

Merged
merged 2 commits into from
Nov 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

### Tools helper code

* Respect `$NXF_HOME` when looking for pipelines with `nf-core list` [[#798](https://github.com/nf-core/tools/issues/798)]

### Template

### Linting
Expand Down
4 changes: 4 additions & 0 deletions nf_core/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ def get_local_nf_workflows(self):
# Try to guess the local cache directory (much faster than calling nextflow)
if len(os.environ.get("NXF_ASSETS", "")) > 0:
nextflow_wfdir = os.environ.get("NXF_ASSETS")
elif len(os.environ.get("NXF_HOME", "")) > 0:
nextflow_wfdir = os.path.join(os.environ.get("NXF_HOME"), "assets")
else:
nextflow_wfdir = os.path.join(os.getenv("HOME"), ".nextflow", "assets")
if os.path.isdir(nextflow_wfdir):
Expand Down Expand Up @@ -348,6 +350,8 @@ def get_local_nf_workflow_details(self):
# Try to guess the local cache directory
if len(os.environ.get("NXF_ASSETS", "")) > 0:
nf_wfdir = os.path.join(os.environ.get("NXF_ASSETS"), self.full_name)
elif len(os.environ.get("NXF_HOME", "")) > 0:
nf_wfdir = os.path.join(os.environ.get("NXF_HOME"), "assets")
else:
nf_wfdir = os.path.join(os.getenv("HOME"), ".nextflow", "assets", self.full_name)
if os.path.isdir(nf_wfdir):
Expand Down
7 changes: 5 additions & 2 deletions nf_core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,12 @@ def fetch_wf_config(wf_path):
cache_basedir = None
cache_path = None

# Nextflow home directory - use env var if set, or default to ~/.nextflow
nxf_home = os.environ.get("NXF_HOME", os.path.join(os.getenv("HOME"), ".nextflow"))

# Build a cache directory if we can
if os.path.isdir(os.path.join(os.getenv("HOME"), ".nextflow")):
cache_basedir = os.path.join(os.getenv("HOME"), ".nextflow", "nf-core")
if os.path.isdir(nxf_home):
cache_basedir = os.path.join(nxf_home, "nf-core")
if not os.path.isdir(cache_basedir):
os.mkdir(cache_basedir)

Expand Down