Override Nixpacks default Python version for a Node build
selfagency
HOBBYOP

a year ago

This is NOT a Railway customer question, though I am also a Railway customer. This is a Nixpacks local build question.

I'm trying to build an OLD app that runs on Node 14, which requires a version of Python earlier than 3.11, for node-gyp I assume. I've tried NIXPACKS_PYTHON_VERSION=3.9 and NIXPACKS_PKGS=python39, as well as adding a .python-version file and a runtime.txt file, and, in all cases, Python 3.11 is installed (in the case of NIXPACKS_PKGS alongside 3.9), and the default system Python is 3.11. How do I override it so it uses 3.9?

21.61 copying path '/nix/store/nxxghhhia9x1skpqfak4z407yy0mbnnd-python3-3.11.5' from 'https://cache.nixos.org'...
[...]
62.90 Node.js configure: Found Python 3.11.5...
62.90 Please use python3.10 or python3.9 or python3.8 or python3.7 or python3.6 or python3.5 or python2.7.
63.09 error: builder for '/nix/store/fs2bjgbwk2ivs0h9cljih0j9n25nxhxf-nodejs-14.21.3.drv' failed with exit code 1
63.13 error: 1 dependencies of derivation '/nix/store/y1l1bkja9dyhg8bxv4lmhx1cgr41641g-bf744fe90419885eefced41b3e5ae442d732712d-env.drv' failed to build
------

 1 warning found (use docker --debug to expand):
 - UndefinedVar: Usage of undefined variable '$NIXPACKS_PATH' (line 18)
Dockerfile:8
--------------------
   6 |     
   7 |     COPY .nixpacks/nixpkgs-bf744fe90419885eefced41b3e5ae442d732712d.nix .nixpacks/nixpkgs-bf744fe90419885eefced41b3e5ae442d732712d.nix
   8 | >>> RUN nix-env -if .nixpacks/nixpkgs-bf744fe90419885eefced41b3e5ae442d732712d.nix && nix-collect-garbage -d
   9 |     
  10 |     
--------------------
ERROR: failed to solve: process "/bin/bash -ol pipefail -c nix-env -if .nixpacks/nixpkgs-bf744fe90419885eefced41b3e5ae442d732712d.nix && nix-collect-garbage -d" did not complete successfully: exit code: 100
Error: Docker build failed

2 Replies

selfagency
HOBBYOP

a year ago

N/A


a year ago

hmmm I don't even think the current version of Nixpacks will build a node 14 app even if it doesn't rely on Python, can you try a much older version of Nixpacks?


Loading...