Reproductibility with Nix, Flake and R langage

Hi there,

I’m actually learning Nix, NixOS in order to enhance my scientific work and publication workflow.

I discuss about reproducibility with people on Discord, and i also open a discussion on SO on this subject (r - Better reproductibility of rPackages (pin version of packages) in nix in comparison to guix - Stack Overflow)

In short, i’m interested by the possibility to design a flake that compile R files , produce graphics with R packages version pinned. My goal is to give this Flake with my paper to help people reproducing my analysis in 5/10 years If you have any experience on this, i’m interested.

Why ? Because, as you perhaps know, Python but also R ecosystems are not designed for reproducibility (lot of example on the web 1) even at middle term. With Poetry and some other projects in python, things tend to be better, but with R, you have REnv that lock dependency but fail if a package was originally installed through a CRAN-available binary, but that binary is no longer available. … If you update your version of R, there are big chances that R packages don’t compile / follow / break / disapear / don’t work in short. I also see that mach-nix nix package answer part of this question with Python.


Actually the only solution to searching and pinning a specific version of R and RPackages would be to search nixpkgs old commit using an unoficial index : Searching and installing old versions of Nix packages – Marcelo Lazaroni – Developing for the Interwebs

This is not very user friendly …

Is there another possibility that comes to your mind ? Using REnv R packages in combination with NixOS will perhaps make the job ? That don’t solve the problem of binary, but possibly that solve the problem of source compilation ?

There is also some project and discussion between Software Heritage (https://www.softwareheritage.org/) and nix and i’m really interested by news and example of code/derivation/flake to made this a reality on my day to day scientific workflow :

4 Likes