Save and rerun conveniently using stored value of "params"?

For reproducibility, I’d like to save a snapshot of the value of “params” when nextflow run is launched. Ideally the params would be saved in such a way that the user could easily use it as input to a rerun of the pipeline.

Is there an existing convenient way to do that?

There’s the nf-prov Nextflow plugin for provenance information. Among the things it does is save information about your run, including pipeline parameters. See the example below:

nextflow.config

plugins {
  id 'nf-prov'
}

prov {
  enabled = true
  formats {
    bco {
      file = 'bco.json'
      overwrite = true
    }
  }
}

Then nextflow run hello --foo bar --zoo beh. In the bco.json file created, you will find the params used in that run: