Uri David Akavia
01/20/2026, 8:39 PMAmmar Aziz
01/21/2026, 2:47 AMAmmar Aziz
01/21/2026, 2:49 AMconfig/modules.config eg https://github.com/nf-core/pixelator/blob/2.3.0/conf/modules.configAmmar Aziz
01/21/2026, 2:57 AMI'd like to have the optional arguments present in a file somewhere, so people will know what to use, including when incorporating into pipelines.This is something I'm interested in as well but I have a feeling it falls outside the scope of the nf-core modules. Take the
samtools_depth module https://github.com/nf-core/modules/blob/master/modules/nf-core/samtools/depth/main.nf
The actual script part is tiny:
samtools \\
depth \\
--threads ${task.cpus-1} \\
$args \\
$positions \\
-o ${prefix}.tsv \\
$bam
Even though the number of possible arguments are a lot. I think it's expected that the user knows how to use the tool and would seek out the documentation or seek out its usage in other nf-core pipelines.Ammar Aziz
01/21/2026, 2:59 AMJames Fellows Yates
01/21/2026, 7:47 AMI think it's expected that the user knows how to use the tool and would seek out the documentation or seek out its usage in other nf-core pipelines.Our philosphy is that it's the pipeline developers' responsibility to be familiar with the tool they are adding to a pipeline, and thus responsible for deciding what to 'expose' are the allowed Arguments for module. In many cases a pipeline will not be compatible with all the options a tool may have - so the pipeline developer needs to control for this. We also don't want to duplicate documentation from the tool itself, a user should ideally kknow what tool they are selecting already.
Simon Pearce
01/21/2026, 9:12 AMAmmar Aziz
01/21/2026, 10:31 AMUri David Akavia
01/21/2026, 4:07 PMUri David Akavia
01/21/2026, 4:18 PMSimon Pearce
01/21/2026, 4:23 PMSimon Pearce
01/21/2026, 4:24 PMSimon Pearce
01/21/2026, 4:26 PMSimon Pearce
01/21/2026, 4:26 PMJames Fellows Yates
01/22/2026, 10:20 AMThe specification for a module says that optional arguments MUST be provided in args, but it actually means that optional arguments should be in the pipeline modules.conf when using this module. So the module definition does not have any optional arguments.Ah ok this sounds like bad phrasing. I guess
provided in shoudl be replaced supported by args, . I can see why it might be unclear now!James Fellows Yates
01/22/2026, 10:34 AM## Optional command arguments
All _non-mandatory_ command-line tool _non-file_ arguments MUST supported in the module via the `$task.ext.args` variable.
The `$args` variable MUST be placed in the module's tool command to allow optional and/or dynamic variables to be specified by a user or a developer.
The contents of this variable is specified by a pipeline developer or user in with the `ext.args` process variable in a `modules.config` or other Nextflow config file using a closure.
The `$ext.args` variable can also be used in module tests to increase the test coverage of a tool's functionality through a companion `nextflow.config` alongside the test files themselves.
```groovy {2} title="<module>.nf"
script:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
"""
fastqc \\
$args \\
<...>
"""
groovy {3-6} title="modules.config"
process {
withName: <module> {
ext.args = { [ // Assign a closure which returns a string
'--quiet',
params.fastqc_kmer_size ? "-k ${params.fastqc_kmer_size}" : '' // Parameter-dependent values can be provided in this way
].join(' ') } // Join converts the list to a string.
ext.prefix = { "${meta.id}" } // A closure can be used to access variables defined in the script
}
}
:::info{title="Rationale" collapse}
Passing arguments via ext.args splits how information is passed to a module, making it harder to understand where module inputs are defined.
Using ext.args provides more flexibility to users.
As ext.args is derived from the configuration (e.g.,, modules.config), advanced users can overwrite the default ext.args and supply their own arguments to modify the behaviour of a module.
This can increase the capabilities of a pipeline beyond what the original developers intended.
Initially, these were passed via the main workflow script using custom functions (e.g., addParams) and other additional nf-core custom methods, but this syntax overhead and other limitations were more difficult for pipeline developers to use and understand. Using the 'native' ext functionality provided by Nextflow was easier to understand, maintain, and use.
Sample-specific parameters can still be provided to an instance of a process by storing these in meta, and providing these to the ext.args definition in modules.config.
A closure is used to make Nextflow evaluate the code in the string:
groovy
ext.args = { "--id ${meta.id}" }
:::
```James Fellows Yates
01/22/2026, 10:34 AMUri David Akavia
01/22/2026, 10:57 AMext.args process variable in a modules.config or other Nextflow config file using a closure. Config file are present in pipelines and subworkflows, not for each individual module.
What I added is in bold. Feel free to change the phrasing. Thank you!James Fellows Yates
01/23/2026, 7:45 AM