diff --git a/CHANGELOG.md b/CHANGELOG.md index 13192a2bff..0ebd55dbe8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/nf_core/list.py b/nf_core/list.py index c81d35bd42..45cbeb5d18 100644 --- a/nf_core/list.py +++ b/nf_core/list.py @@ -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): @@ -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): diff --git a/nf_core/utils.py b/nf_core/utils.py index f09c4bd3cb..2e6388db31 100644 --- a/nf_core/utils.py +++ b/nf_core/utils.py @@ -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)