A posteriori Nix shells
You have a dirty software environment and you want to get Nix shells with the same packages and versions.
Describe the different shells, packages, and desired versions in a YAML file:
- shell: analysis
packages:
- name: python310
version: "3.10.8"
with_packages:
- name: numpy
version: "1.24.2"
- name: matplotlib
version: "3.7.1"
- shell: dev
packages:
- name: gcc
version: "12.3.0"
- name: cmake
version: "3.24.3"
-
shellsets the name of the shell -
packagesis a list of pairs (name,version) -
for some packages (
python,R, ...), you can use thewith_packagesfields to add some packages (numpyandmatplotlibin the example above)
Then run mop:
mop envs.yamlmop will generate a flake.nix file that tries to match as best as it can the desired environments.
-
mopcalls Nixhub under the hood to retrieve the correctnixpkgscommits -
you do want to call a nix formatter on the generated
flake.nix!! -
for now, the
with_packagessupports fullypython, and partiallyR -
it might require you to edit the
flake.nixto fill up somesha256orhash