Same here! I am in exactly the same situation. I have inherited a legacy Django code base with the previous build environment being a different distro as well. For years I have been building my Django websites using pip tools and a Python virtual environment locally on Manjaro and deployed to Heroku (which is an Ubtuntu slug).
I appreciate that Nix offers a more nuanced way to manage development environments but I feel like I am not quite ready to fully commit to Flakes and Home Manager yet because I am also relatively new to Nix and NixOS. I am still ‘just getting my feet wet’ so to speak with nixpkgs.
Perhaps I can jump in here and use my own legacy Django project to serve as an example to add context to your inquiry, @mapper.
I’ve explored building a Django development setup using configurtation.nix
with these lines explicitly:
environment.systemPackages = [
# Python-Django development
python3
python312Packages.pip
heroku
postgresql
python312Packages.psycopg2
python312Packages.eggUnpackHook
python312Packages.eggBuildHook
python312Packages.eggInstallHook
];
Afterwards I initialized my virtual enviornmet with: $ python -m venv venv
as I’ve been accustomed to with my prior distro. Then I activated it. Next I attempted to install all the Python packages via requirements.txt
as usual but pip is choking when trying to install / build / configure Postgres and adjacent libraries showing this error:
My broken pip wheel
Collecting psycopg2==2.9.10 (from -r requirements.txt (line 61))
Using cached psycopg2-2.9.10.tar.gz (385 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... error
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [5 lines of output]
running egg_info
writing psycopg2.egg-info/PKG-INFO
writing dependency_links to psycopg2.egg-info/dependency_links.txt
writing top-level names to psycopg2.egg-info/top_level.txt
Error: pg_config --libdir failed:
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.
As you can see in the traceback, there are a few references to Python and egg_info
which after a few Google searches lead me to adding those 3 “egg hooks” packages in my configuration.nix
. After switching and upgrading these additonal packages, that did not resolve the pip errors.
I am willing to learn how to use Flakes and write Nix expressions, but I am just wondering if it is possible for now to get a Django project up and running on NixOS the old fashioned way using pip? Or is it absolutely mandatory for all NixOS developers to manage their buiild enviornments in Flakes and the Nix language?
Another interesting consideration: Heroku builds the slug based on an imported requirements.txt
so if my new local development environment is written in Nix, it won’t be compatible with Heroku. I will need to arrange for some alternate webhost. Is that a fair assesment?