Skill Tracer
Skills › Scientific Agent Skills › nextflow › configuration.md

configuration.md

278 lines · skills/nextflow/references/configuration.md at 5f2bc03

Open on GitHub

Most marks come from matching words in the file, so treat them as pointers.

1# Nextflow Configuration, Executors & CLI
2
3How to configure, scale, cache, observe, and drive Nextflow runs. Targets stable 26.04.6. Sources: [configuration](https://docs.seqera.io/nextflow/config), [runtime config](https://docs.seqera.io/nextflow/reference/config), [executors](https://docs.seqera.io/nextflow/executor), and [cache](https://docs.seqera.io/nextflow/cache-and-resume). HPC/cloud configurations below are illustrative and were not submitted.
4

Nextflow Configuration, Executors & CLI

How to configure, scale, cache, observe, and drive Nextflow runs. Targets stable 26.04.6. Sources: configuration, runtime config, executors, and cache. HPC/cloud configurations below are illustrative and were not submitted.

Raw lines 1 to 4
5## Table of Contents
6
7- [nextflow.config and scopes](#nextflowconfig-and-scopes)
8- [Profiles](#profiles)
9- [Process selectors](#process-selectors-withname-withlabel)
10- [Executors](#executors)
11- [Cloud executors](#cloud-executors)
12- [Caching and -resume](#caching-and--resume)
13- [Tracing and reports](#tracing-and-reports)
14- [The nextflow CLI](#the-nextflow-cli)
15- [Environment variables](#environment-variables)

Table of Contents

  • nextflow.config and scopes
  • Profiles
  • Process selectors
  • Executors
  • Cloud executors
  • Caching and -resume
  • Tracing and reports
  • The nextflow CLI
  • Environment variables
Raw lines 5 to 16
17## nextflow.config and scopes
19`nextflow.config` configures a run **without touching pipeline code**. Files are auto-loaded and merged in **increasing precedence**: (1) `$NXF_HOME/config` (`~/.nextflow/config`), (2) `nextflow.config` in the **project** dir (where the script lives), (3) `nextflow.config` in the **launch** dir (current working dir), (4) each `-c custom.config` (repeatable). Using `-C file` instead loads **only** that file and ignores every other source. CLI `--param`/`-params-file` override config params. Values are grouped into **scopes**.
21```groovy
22// nextflow.config
23params {
24 input = null
25 outdir = 'results'
26 genome = 'GRCh38'
29process {
30 cpus = 2
31 memory = '4 GB'
32 errorStrategy = 'retry'
33 maxRetries = 2
34 container = 'ubuntu:22.04'
37executor {
38 queueSize = 100 // max parallel tasks submitted
39 submitRateLimit = '10/1min'
42docker.enabled = true // pick ONE container engine
43// singularity.enabled = true
44// conda.enabled = true
46timeline.enabled = true
47report.enabled = true
48trace.enabled = true
50manifest {
51 name = 'my/pipeline'
52 nextflowVersion = '!>=26.04.0' // enforce a minimum engine version
54```
56Key scopes: `params`, `process`, `executor`, `docker`/`singularity`/`apptainer`/`podman`/`conda`/`wave`, `aws`/`google`/`azure`/`k8s`, `tower` (Seqera Platform), `report`/`timeline`/`trace`/`dag`, `manifest`, `env`, `cleanup`.
58Assignment uses `=`. Use the dotted form (`docker.enabled = true`) or block form (`docker { enabled = true }`) interchangeably.

nextflow.config and scopes

nextflow.config configures a run without touching pipeline code. Files are auto-loaded and merged in increasing precedence: (1) $NXF_HOME/config (~/.nextflow/config), (2) nextflow.config in the project dir (where the script lives), (3) nextflow.config in the launch dir (current working dir), (4) each -c custom.config (repeatable). Using -C file instead loads only that file and ignores every other source. CLI --param/-params-file override config params. Values are grouped into scopes.

// nextflow.config
params {
    input  = null
    outdir = 'results'
    genome = 'GRCh38'
}

process {
    cpus   = 2
    memory = '4 GB'
    errorStrategy = 'retry'
    maxRetries    = 2
    container = 'ubuntu:22.04'
}

executor {
    queueSize     = 100        // max parallel tasks submitted
    submitRateLimit = '10/1min'
}

docker.enabled = true          // pick ONE container engine
// singularity.enabled = true
// conda.enabled = true

timeline.enabled = true
report.enabled   = true
trace.enabled    = true

manifest {
    name = 'my/pipeline'
    nextflowVersion = '!>=26.04.0'   // enforce a minimum engine version
}

Key scopes: params, process, executor, docker/singularity/apptainer/podman/conda/wave, aws/google/azure/k8s, tower (Seqera Platform), report/timeline/trace/dag, manifest, env, cleanup.

Assignment uses =. Use the dotted form (docker.enabled = true) or block form (docker { enabled = true }) interchangeably.

Raw lines 17 to 59
60## Profiles
62A **profile** is a named bundle of config, activated with `-profile`. nf-core pipelines ship profiles for each container engine plus a `test` profile.
64```groovy
65profiles {
66 standard { process.executor = 'local' }
68 docker { docker.enabled = true; docker.runOptions = '-u $(id -u):$(id -g)' }
69 singularity { singularity.enabled = true; singularity.autoMounts = true }
70 conda { conda.enabled = true }
72 slurm {
73 process.executor = 'slurm'
74 process.queue = 'compute'
75 }
77 test {
78 params.input = "${baseDir}/assets/test_samplesheet.csv"
79 params.genome = 'R64-1-1'
80 }
82```
84Activate (combine with commas; **order matters** — later profiles override earlier):
86```bash
87nextflow run main.nf -profile test,singularity
88```
90Choose one execution environment profile (`docker`, `singularity`, or `conda`). Site/executor profiles can be combined with it; verify the resolved configuration. If no `-profile` is given, the `standard` profile (if defined) is used.
92> Ordering caveat: with the legacy parser, profiles are applied in the **order they are defined in the config**, regardless of CLI order; with the strict parser (default in 26.04) they apply in **CLI order**. To stay safe, avoid combining profiles that set the *same* option to conflicting values.

Profiles

A profile is a named bundle of config, activated with -profile. nf-core pipelines ship profiles for each container engine plus a test profile.

profiles {
    standard { process.executor = 'local' }

    docker      { docker.enabled = true; docker.runOptions = '-u $(id -u):$(id -g)' }
    singularity { singularity.enabled = true; singularity.autoMounts = true }
    conda       { conda.enabled = true }

    slurm {
        process.executor = 'slurm'
        process.queue    = 'compute'
    }

    test {
        params.input  = "${baseDir}/assets/test_samplesheet.csv"
        params.genome = 'R64-1-1'
    }
}

Activate (combine with commas; order matters — later profiles override earlier):

nextflow run main.nf -profile test,singularity

Choose one execution environment profile (docker, singularity, or conda). Site/executor profiles can be combined with it; verify the resolved configuration. If no -profile is given, the standard profile (if defined) is used.

Ordering caveat: with the legacy parser, profiles are applied in the order they are defined in the config, regardless of CLI order; with the strict parser (default in 26.04) they apply in CLI order. To stay safe, avoid combining profiles that set the same option to conflicting values.
Raw lines 60 to 93
94## Process selectors (withName, withLabel)
96Target configuration at specific processes inside the `process` scope. This is how nf-core sets per-tool resources and arguments without editing modules.
98```groovy
99process {
100 // by resource label
101 withLabel: 'process_low' { cpus = 2; memory = 6.GB; time = 4.h }
102 withLabel: 'process_medium' { cpus = 6; memory = 36.GB; time = 8.h }
103 withLabel: 'process_high' { cpus = 12; memory = 72.GB; time = 16.h }
105 // by process name (regex / fully-qualified WORKFLOW:SUB:PROCESS)
106 withName: 'FASTQC' { cpus = 4 }
107 withName: '.*:ALIGN' {
108 // Keep the module’s pinned environment; it must contain every piped tool.
109 ext.args = '-M' // injected into the script as task.ext.args
110 publishDir = [ path: { "${params.outdir}/bam" }, mode: 'copy' ]
111 }
113```
115Precedence: `withName` overrides `withLabel` overrides generic `process` settings. nf-core keeps all `withName` blocks in `conf/modules.config`.

Process selectors (withName, withLabel)

Target configuration at specific processes inside the process scope. This is how nf-core sets per-tool resources and arguments without editing modules.

process {
    // by resource label
    withLabel: 'process_low'    { cpus = 2;  memory = 6.GB;  time = 4.h }
    withLabel: 'process_medium' { cpus = 6;  memory = 36.GB; time = 8.h }
    withLabel: 'process_high'   { cpus = 12; memory = 72.GB; time = 16.h }

    // by process name (regex / fully-qualified WORKFLOW:SUB:PROCESS)
    withName: 'FASTQC' { cpus = 4 }
    withName: '.*:ALIGN' {
        // Keep the module’s pinned environment; it must contain every piped tool.
        ext.args  = '-M'                 // injected into the script as task.ext.args
        publishDir = [ path: { "${params.outdir}/bam" }, mode: 'copy' ]
    }
}

Precedence: withName overrides withLabel overrides generic process settings. nf-core keeps all withName blocks in conf/modules.config.

Raw lines 94 to 116
117## Executors
119The executor maps tasks onto compute. Default is `local` (subprocesses on the current machine). Set globally or per-process.
121```groovy
122process.executor = 'slurm' // global
123// or
124process { withLabel: 'process_high' { executor = 'slurm'; queue = 'bigmem' } }
125```
127| Executor | Platform |
128|----------|----------|
129| `local` | The current machine (default) |
130| `slurm` | SLURM clusters |
131| `sge` | Sun/Univa-compatible Grid Engine |
132| `lsf` | IBM Spectrum LSF |
133| `pbs` / `pbspro` | PBS / Torque / PBS Pro |
134| `awsbatch` | AWS Batch |
135| `google-batch` | Google Cloud Batch |
136| `azurebatch` | Azure Batch |
137| `k8s` | Kubernetes |
138| `flux`, `hyperqueue`, `oar`, `moab` | Other schedulers |
140SLURM example with cluster options:
142```groovy
143process {
144 executor = 'slurm'
145 queue = 'compute' // SLURM partition
146 clusterOptions = '--account=lab123'
148executor {
149 queueSize = 200 // max jobs queued at once
150 submitRateLimit = '10/1min' // throttle submissions
151 perCpuMemAllocation = true // emit --mem-per-cpu instead of --mem (some clusters require this)
153```

Executors

The executor maps tasks onto compute. Default is local (subprocesses on the current machine). Set globally or per-process.

process.executor = 'slurm'        // global
// or
process { withLabel: 'process_high' { executor = 'slurm'; queue = 'bigmem' } }
ExecutorPlatform
localThe current machine (default)
slurmSLURM clusters
sgeSun/Univa-compatible Grid Engine
lsfIBM Spectrum LSF
pbs / pbsproPBS / Torque / PBS Pro
awsbatchAWS Batch
google-batchGoogle Cloud Batch
azurebatchAzure Batch
k8sKubernetes
flux, hyperqueue, oar, moabOther schedulers

SLURM example with cluster options:

process {
    executor   = 'slurm'
    queue      = 'compute'             // SLURM partition
    clusterOptions = '--account=lab123'
}
executor {
    queueSize       = 200              // max jobs queued at once
    submitRateLimit = '10/1min'        // throttle submissions
    perCpuMemAllocation = true         // emit --mem-per-cpu instead of --mem (some clusters require this)
}
Raw lines 117 to 154
155## Cloud executors
157Each cloud needs its scope configured, credentials/permissions, a compatible task image, and a work directory visible to its tasks. AWS/Google/Azure Batch examples below use object storage. Kubernetes commonly uses a shared persistent volume or a supported Fusion setup; object storage is not a universal executor requirement.
159```groovy
160// AWS Batch
161process.executor = 'awsbatch'
162process.queue = 'my-batch-queue'
163aws {
164 region = 'us-east-1'
165 batch.cliPath = '/home/ec2-user/miniconda/bin/aws'
167workDir = 's3://my-bucket/work'
168```
170```groovy
171// Google Cloud Batch
172process.executor = 'google-batch'
173google.project = 'my-gcp-project'
174google.location = 'us-central1'
175workDir = 'gs://my-bucket/work'
176```
178For Azure use `azurebatch` + the `azure` scope with `workDir = 'az://...'`. For Kubernetes configure the `k8s` executor; `nextflow run` submits tasks from the launcher, while `nextflow kuberun` additionally deploys the launcher as a pod and requires `kubectl` (remote pipelines only). **Wave + Fusion** can support cloud I/O (see `references/containers.md`). Seqera Platform (Tower) monitoring: set `tower.enabled = true` and `TOWER_ACCESS_TOKEN`, or run with `-with-tower`.

Cloud executors

Each cloud needs its scope configured, credentials/permissions, a compatible task image, and a work directory visible to its tasks. AWS/Google/Azure Batch examples below use object storage. Kubernetes commonly uses a shared persistent volume or a supported Fusion setup; object storage is not a universal executor requirement.

// AWS Batch
process.executor = 'awsbatch'
process.queue    = 'my-batch-queue'
aws {
    region = 'us-east-1'
    batch.cliPath = '/home/ec2-user/miniconda/bin/aws'
}
workDir = 's3://my-bucket/work'
// Google Cloud Batch
process.executor = 'google-batch'
google.project   = 'my-gcp-project'
google.location  = 'us-central1'
workDir = 'gs://my-bucket/work'

For Azure use azurebatch + the azure scope with workDir = 'az://...'. For Kubernetes configure the k8s executor; nextflow run submits tasks from the launcher, while nextflow kuberun additionally deploys the launcher as a pod and requires kubectl (remote pipelines only). Wave + Fusion can support cloud I/O (see references/containers.md). Seqera Platform (Tower) monitoring: set tower.enabled = true and TOWER_ACCESS_TOKEN, or run with -with-tower.

Raw lines 155 to 179
Runs code bin/aws :165
180## Caching and -resume
182`-resume` skips tasks whose inputs are unchanged, reusing outputs from the `work/` directory.
184```bash
185nextflow run main.nf -resume # resume the last run
186nextflow run main.nf -resume <session-id> # resume a specific session (see `nextflow log`)
187```
189How caching works: each task gets a hash of its inputs, script text, container, and relevant task settings. Default file hashing uses path, size, and modification time, not content. A matching cache entry is reusable only when required outputs and a valid exit status remain in its work directory.
191**Debugging cache misses** (a task re-runs when you expected a hit):
192- Run `nextflow log <run> -f hash,name,status,workdir` to inspect tasks.
193- Diff the task hashes of two runs: `nextflow -log a.log run … -dump-hashes json` then `nextflow -log b.log run … -resume -dump-hashes json`, and compare the `cache hash` entries to see exactly what changed.
194- Common causes: a changed input file timestamp/content, an edited script, a different container tag, a non-deterministic input order, an undeclared closure variable (use `def`), or using `cache false`.
195- `cache 'lenient'` hashes file path and size, ignoring modification time; it can help inconsistent shared-filesystem timestamps but can miss same-size content changes. `cache 'deep'` hashes file content, with extra I/O cost. Keep inputs immutable or choose content hashing when needed.
196- Preserve both the task metadata cache (normally `.nextflow/cache` under the launch directory) and the task **work directories**. Published results alone cannot restore resumability; deleting either store prevents affected tasks from being reused.
198**Work directory management**: `work/` grows fast. Clean with:
200```bash
201nextflow clean -f -before <run_name> # remove work data before a run
202nextflow clean -f -but <run_name> # keep one run, remove others
203```
205Set `cleanup = true` only when you intend to discard resumability: it deletes work directories after success. Preview cleanup with `nextflow clean -n ...` and review targets before `-f`. Archive publish outputs and provenance first.

Caching and -resume

-resume skips tasks whose inputs are unchanged, reusing outputs from the work/ directory.

nextflow run main.nf -resume                 # resume the last run
nextflow run main.nf -resume <session-id>    # resume a specific session (see `nextflow log`)

How caching works: each task gets a hash of its inputs, script text, container, and relevant task settings. Default file hashing uses path, size, and modification time, not content. A matching cache entry is reusable only when required outputs and a valid exit status remain in its work directory.

Debugging cache misses (a task re-runs when you expected a hit):

  • Run nextflow log <run> -f hash,name,status,workdir to inspect tasks.
  • Diff the task hashes of two runs: nextflow -log a.log run … -dump-hashes json then nextflow -log b.log run … -resume -dump-hashes json, and compare the cache hash entries to see exactly what changed.
  • Common causes: a changed input file timestamp/content, an edited script, a different container tag, a non-deterministic input order, an undeclared closure variable (use def), or using cache false.
  • cache 'lenient' hashes file path and size, ignoring modification time; it can help inconsistent shared-filesystem timestamps but can miss same-size content changes. cache 'deep' hashes file content, with extra I/O cost. Keep inputs immutable or choose content hashing when needed.
  • Preserve both the task metadata cache (normally .nextflow/cache under the launch directory) and the task work directories. Published results alone cannot restore resumability; deleting either store prevents affected tasks from being reused.

Work directory management: work/ grows fast. Clean with:

nextflow clean -f -before <run_name>    # remove work data before a run
nextflow clean -f -but <run_name>       # keep one run, remove others

Set cleanup = true only when you intend to discard resumability: it deletes work directories after success. Preview cleanup with nextflow clean -n ... and review targets before -f. Archive publish outputs and provenance first.

Raw lines 180 to 206
207## Tracing and reports
209Observability flags (or enable the matching config scope):
211| Flag | Produces |
212|------|----------|
213| `-with-report report.html` | Resource-usage HTML report per task |
214| `-with-timeline timeline.html` | Timeline of task execution |
215| `-with-trace trace.txt` | Tab-separated trace of every task (cpu, mem, time, status) |
216| `-with-dag flow.html` (or `.png`/`.mmd`/`.dot`) | Workflow DAG diagram |
217| `-with-tower` | Stream metrics to Seqera Platform |
218| `-with-weblog <url>` | POST run events to an HTTP endpoint |
220```bash
221nextflow run main.nf -profile docker \
222 -with-report -with-trace -with-timeline -with-dag flow.html
223```

Tracing and reports

Observability flags (or enable the matching config scope):

FlagProduces
-with-report report.htmlResource-usage HTML report per task
-with-timeline timeline.htmlTimeline of task execution
-with-trace trace.txtTab-separated trace of every task (cpu, mem, time, status)
-with-dag flow.html (or .png/.mmd/.dot)Workflow DAG diagram
-with-towerStream metrics to Seqera Platform
-with-weblog <url>POST run events to an HTTP endpoint
nextflow run main.nf -profile docker \
  -with-report -with-trace -with-timeline -with-dag flow.html
Raw lines 207 to 224
225## The nextflow CLI
227```bash
228nextflow run <pipeline> [options] # <pipeline> = path, .nf file, or github user/repo
229```
231| Option | Meaning |
232|--------|---------|
233| `-profile a,b` | Activate config profiles (comma-separated, ordered) |
234| `-resume [id]` | Reuse cached results |
235| `-r <rev>` | Git revision: tag, branch, or commit (for remote pipelines) |
236| `-params-file f.yml` | Load params from YAML/JSON |
237| `-c file.config` | Add an extra config file (highest-precedence config) |
238| `-w <dir>` / `workDir` | Set the work directory (local path or cloud URI) |
239| `-stub-run` (`-stub`) | Execute stubs where defined; other task scripts and `eval()` outputs still run |
240| `-entry <name>` | Run a specific named workflow as the entry point |
241| `-process.<dir> <val>` | Override a process directive at launch |
242| `-bg` | Run in background; `-ansi-log false` for plain logs |
243| `-dump-channels` | Print channel contents (with `.dump()`) |
244| `-preview` | Preview the workflow without executing tasks; setup/configuration can still access remote resources |
246Other top-level commands:
248```bash
249nextflow log [run] [-f fields] # list past runs / fields of a run
250nextflow pull user/repo # download/update a remote pipeline
251nextflow list # list downloaded pipelines
252nextflow info user/repo # show pipeline metadata
253nextflow drop user/repo # delete a downloaded pipeline
254nextflow clean -f -before <run> # delete work data
255nextflow config [-profile p] # print the resolved configuration
256nextflow inspect <pipeline> # resolve per-process containers without running
257nextflow lint <file|dir> # check/format scripts & config (strict syntax)
258nextflow self-update # update the Nextflow engine
259```

The nextflow CLI

nextflow run <pipeline> [options]   # <pipeline> = path, .nf file, or github user/repo
OptionMeaning
-profile a,bActivate config profiles (comma-separated, ordered)
-resume [id]Reuse cached results
-r <rev>Git revision: tag, branch, or commit (for remote pipelines)
-params-file f.ymlLoad params from YAML/JSON
-c file.configAdd an extra config file (highest-precedence config)
-w <dir> / workDirSet the work directory (local path or cloud URI)
-stub-run (-stub)Execute stubs where defined; other task scripts and eval() outputs still run
-entry <name>Run a specific named workflow as the entry point
-process.<dir> <val>Override a process directive at launch
-bgRun in background; -ansi-log false for plain logs
-dump-channelsPrint channel contents (with .dump())
-previewPreview the workflow without executing tasks; setup/configuration can still access remote resources

Other top-level commands:

nextflow log [run] [-f fields]      # list past runs / fields of a run
nextflow pull   user/repo           # download/update a remote pipeline
nextflow list                       # list downloaded pipelines
nextflow info   user/repo           # show pipeline metadata
nextflow drop   user/repo           # delete a downloaded pipeline
nextflow clean  -f -before <run>    # delete work data
nextflow config [-profile p]        # print the resolved configuration
nextflow inspect <pipeline>         # resolve per-process containers without running
nextflow lint   <file|dir>          # check/format scripts & config (strict syntax)
nextflow self-update                # update the Nextflow engine
Raw lines 225 to 260
261## Environment variables
263| Variable | Effect |
264|----------|--------|
265| `NXF_VER` | Pin the Nextflow engine version for the run |
266| `NXF_WORK` | Default work directory |
267| `NXF_HOME` | Nextflow home (`~/.nextflow`) |
268| `NXF_SINGULARITY_CACHEDIR` / `NXF_APPTAINER_CACHEDIR` | Where SIF images are cached (set on HPC!) |
269| `NXF_CONDA_CACHEDIR` | Cached conda envs |
270| `NXF_CLOUDCACHE_PATH` | Store the task cache in object storage (e.g. `s3://bucket/cache`) for cloud runs |
271| `NXF_SYNTAX_PARSER=v2` | Strict parser, default in 26.04; `v1` is a legacy migration fallback |
272| `NXF_OPTS` | JVM options, e.g. `-Xms2g -Xmx4g` for big runs |
273| `TOWER_ACCESS_TOKEN` | Seqera Platform token (with `-with-tower`) |
274| `NXF_OFFLINE=true` | Prevent automatic remote project/plugin downloads and version checks; not a network sandbox |
276`NXF_OFFLINE` does not block remote input reads, container pulls, included HTTP config, task network access or telemetry configured elsewhere. Pre-stage and pin the engine, plugins, modules, configs, images, inputs and references; test with actual network isolation when an air gap is required.
278On HPC, set a shared `NXF_SINGULARITY_CACHEDIR` so image pulls are reused across jobs. See `references/running-pipelines.md` for offline execution.

Environment variables

VariableEffect
NXF_VERPin the Nextflow engine version for the run
NXF_WORKDefault work directory
NXF_HOMENextflow home (~/.nextflow)
NXF_SINGULARITY_CACHEDIR / NXF_APPTAINER_CACHEDIRWhere SIF images are cached (set on HPC!)
NXF_CONDA_CACHEDIRCached conda envs
NXF_CLOUDCACHE_PATHStore the task cache in object storage (e.g. s3://bucket/cache) for cloud runs
NXF_SYNTAX_PARSER=v2Strict parser, default in 26.04; v1 is a legacy migration fallback
NXF_OPTSJVM options, e.g. -Xms2g -Xmx4g for big runs
TOWER_ACCESS_TOKENSeqera Platform token (with -with-tower)
NXF_OFFLINE=truePrevent automatic remote project/plugin downloads and version checks; not a network sandbox

NXF_OFFLINE does not block remote input reads, container pulls, included HTTP config, task network access or telemetry configured elsewhere. Pre-stage and pin the engine, plugins, modules, configs, images, inputs and references; test with actual network isolation when an air gap is required.

On HPC, set a shared NXF_SINGULARITY_CACHEDIR so image pulls are reused across jobs. See references/running-pipelines.md for offline execution.

Raw lines 261 to 278