Creating a python derivation is not trivial. python has already lots of issue with version conflict. So if you need to create one pythonnix derivation, you just hope it does not have dependency.
Otherwise, there is some mitigation, but it’s not easy to deal it.
The easiest one I find is to manually pip install in the shellHook. It does not quite respect nix reproducible philosophy however:
Context
I wanted to install [presenterm-export][] to my local computer, so I could export my markdown slides. Unfortunately, this tool is not present yet in nixpkgs.
I’m using direnv to automatically install the tools when I go to a folder. So I created a flake.nix with the following content:
Since there’s no [presenterm-export][] in the nixpkgs, I need to install manually.
unfortunately, there’s no version 62.3 for this dependency…
I updated my flake.nix with the following:
Unfortunately, it’s not working either:
at /nix/store/avci5b2qjsxkcc17fpl1gralpv6b4xsd-source/pkgs/stdenv/generic/make-derivation.nix:376:7:
375| depsBuildBuild = elemAt (elemAt dependencies 0) 0;
376| nativeBuildInputs = elemAt (elemAt dependencies 0) 1;
| ^
377| depsBuildTarget = elemAt (elemAt dependencies 0) 2;
(stack trace truncated; use '--show-trace' to show the full trace)
error: Python version mismatch in 'python3.12-presenterm-export-0.2.3':
The Python derivation 'python3.12-presenterm-export-0.2.3' depends on a Python derivation
named 'python3.11-ansi2html-1.8.0', but the two derivations use different versions
of Python:
'python3.12-presenterm-export-0.2.3' uses /nix/store/z7xxy35k7620hs6fn6la5fg2lgklv72l-python3-3.12.4
'python3.11-ansi2html-1.8.0' uses /nix/store/sxr2igfkwhxbagri49b8krmcqz168sim-python3-3.11.8
Possible solutions:
* If 'python3.11-ansi2html-1.8.0' is a Python library, change the reference to 'python3.11-ansi2html-1.8.0'
in the propagatedBuildInputs of 'python3.12-presenterm-export-0.2.3' to use a 'python3.11-ansi2html-1.8.0' built from the same
version of Python
* If 'python3.11-ansi2html-1.8.0' is used as a tool during the build, move the reference to
'python3.11-ansi2html-1.8.0' in 'python3.12-presenterm-export-0.2.3' from propagatedBuildInputs to nativeBuildInputs
* If 'python3.11-ansi2html-1.8.0' provides executables that are called at run time, pass its
bin path to makeWrapperArgs:
makeWrapperArgs = [ "--prefix PATH : ${lib.makeBinPath [ ansi2html ] }" ];
at /nix/store/356lp2h4rvgkvlw83pnf092p3f858ph8-source/presenterm-export.nix:14:3
Fail
Not possible to fetch different versions of the dependencies because they would use a different python version, hence a conflict. Not sure if it’s possible or not to use the same python.
❌ dependencies as nativeBuildInputs
I tried to use their one of their option in presenter-export.nix:
However, that did not went well. It downloaded 7GB of data to finally failed with the following error:
error: builder for '/nix/store/rn12q26sw4yxj297q17gwf5g0fdwm61n-audit-3.1.2.drv' failed with exit code 1;
last 10 log lines:
> checking for python version... 3.12
> checking for python platform... linux
> checking for GNU default python prefix... ${prefix}
> checking for GNU default python exec_prefix... ${exec_prefix}
> checking for python script directory (pythondir)... ${PYTHON_PREFIX}/lib/python3.12/site-packages
> checking for python extension module directory (pyexecdir)... ${PYTHON_EXEC_PREFIX}/lib/python3.12/site-packages
> Traceback (most recent call last):
> File "<string>", line 1, in <module>
> ModuleNotFoundError: No module named 'distutils'
> configure: error: Python explicitly requested and python headers were not found
For full logs, run 'nix log /nix/store/rn12q26sw4yxj297q17gwf5g0fdwm61n-audit-3.1.2.drv'.
error: 1 dependencies of derivation '/nix/store/64a12rhqh517x7pdpgy039a0byhql01k-dbus-1.14.10.drv' failed to build
error: 1 dependencies of derivation '/nix/store/vn2bjd4p48d85k4nggb5gddbazjvnrrv-linux-pam-1.6.1.drv' failed to build
error: 1 dependencies of derivation '/nix/store/cjfq86dl1pl6bbxdbmnbg8vzljx2xh6s-cups-2.4.8.drv' failed to build
error: 1 dependencies of derivation '/nix/store/762b7ph538mbgy71wa7dnhr2k4wdxqzh-util-linux-minimal-2.39.4.drv' failed to build
error: 1 dependencies of derivation '/nix/store/wfb10mpxsiskh8jyb179nm57v286g0ca-e2fsprogs-1.47.1.drv' failed to build
error: 1 dependencies of derivation '/nix/store/fap3yi9x0zndgabcyc3mxamp5l2vk133-ghostscript-with-X-10.03.1.drv' failed to build
error: 1 dependencies of derivation '/nix/store/1dkc10jn0y4d0v8gsz5ay0kmhwykzbfc-glib-2.80.3.drv' failed to build
error: 1 dependencies of derivation '/nix/store/41zm6zhiplh8zrnmdakgsfzlicpdqpl8-libarchive-3.7.4.drv' failed to build
error: 1 dependencies of derivation '/nix/store/law0hvlp64scrxmhz6hmscmblz4f5zz6-python3.12-weasyprint-62.2.drv' failed to build
error: 1 dependencies of derivation '/nix/store/mjajks3frz923gfnp9923afv4l346my9-cmake-3.29.6.drv' failed to build
error: 1 dependencies of derivation '/nix/store/rvhjakhyk9xjj14b25xq86rpsm160vdb-python3.12-presenterm-export-0.2.3.drv' failed to build
error: 1 dependencies of derivation '/nix/store/nx8i4d1yqzvsr89iswvfwinj958x41f7-nix-shell-env.drv' failed to build
Fail
Could not make it work when the dependencies were packaged with a different version of python…