jupyterhub / repo2docker

Turn repositories into Jupyter-enabled Docker images
https://repo2docker.readthedocs.io
BSD 3-Clause "New" or "Revised" License
1.62k stars 361 forks source link

Add support for nix flakes #1300

Open jezcope opened 1 year ago

jezcope commented 1 year ago

Proposed change

"Flakes" is an upcoming feature of the nix package manager that allows you to declaratively specify the dependencies for a nix environment as "inputs" and automatically handle pinning inputs with a flake.lock file in the repository, as well as declaratively specifying the configuration of packages as in traditional nix. The environment and its dependencies are defined in flake.nix using a documented schema. Flake inputs can be updated all at once using nix flake update or individually using nix flake lock --update-input <input-name>.

I would like repo2docker to detect the presence of a flake.nix and flake.lock, and automatically build a container using the locked dependencies specified. This will make it easier to manage dependencies in a nix-based binder (currently it's necessary to manually pin dependencies to a specific git commit hash per this example).

Alternative options

It's already possible to use a flake.nix with repo2docker by using the flake-compat library in your default.nix: see https://codeberg.org/jezcope/binder-nix-flakes. However, this:

  1. Requires adding boilerplate to both default.nix and flake.nix for full reproducibility; and
  2. Adds a dependency on flake-compat

A dedicated buildpack would allow any nix flake with a devShell output to be immediately used as a binder.

Who would use this feature?

MyBinder/JupyterHub users who also use nix for reproducibility (there was interest on the Nix Data Science matrix room when I mentioned it). Flakes is described as "experimental" but has been in that state for several years in a stable condition and is increasingly used in production.

How much effort will adding it take?

Not sure about this part! Should be a case of adapting the existing NixBuildPack to install a flakes-compatible version of nix and enable the flakes feature.

Who can do this work?

Python developer familiar with repo2docker internals and nix flakes. I am currently working on adding this feature, to gain a bit more familiarity with the codebase (and because I want it!).

welcome[bot] commented 1 year ago

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively. welcome You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! :wave:
Welcome to the Jupyter community! :tada: