I recently started using NixOS and am trying to learn as much as I can while slowly migrating my setup from my previous OS.
As part of my workflow (on my previous OS), I used to manage multiple python virtual environments, install them using ipykernel and access them on jupyterlab to work on different projects.
I am pretty confident I could stick to my “old” way of doing all of this on my new NixOS installation as well, namely:
$ python3 -m venv my-venv && source my-venv/bin/activate
(my-venv)$ pip install numpy ipykernel
(my-venv)$ python3 -m ipykernel install --name my-venv --user
I could then access the new kernel (my-venv) in jupyterlab (installed system-wide). However, I would be interested in doing all of this “the Nix way”, to have a reproducible setup. Something like:
- Defining my virtual environments (and possibly their paths) in either
configuration.nix
orhome.nix
- Declare the virtual environments as kernels so that they are available in jupyterlab
This way, all my virtual environments would be generated upon successful rebuild, even on a new machine.
I am confident my workflow is somewhat quite common among python developers. Do you have any recommendations, recipes, or tips on how to achieve this on NixOS?