Python Usability
Until recently, this was a bit like asking for being able to program Spring Boot without having to follow Java patterns. Luckily, the Python ecosystem now has uv.
To cut the long story short, it’s likely that the notion of “virtual environment” will disappear in the near future. The PyCon US talk on the future of virtualenvs explains why: You’ll be using uv
to run or install Python CLI tools or applications in one of the following ways:
uv tool install <package>
(then run the tool via its name, e.g.ruff
)uvx <package>
(e.g.uvx pyclean --help
)uv run <package>
(afteruv sync
to install dependencies from apyproject.toml
file)
Python on NixOS
For a pythonic experience on NixOS, I recommend using nix-ld
to tame library dependencies that Python packages may have and install both all Python versions (e.g. uv python install 3.13
) and their Python packages using uv, exclusively.
# Don't install Python system packages, only uv!
environment.systemPackages = [ pkgs.uv ];
# Allow dynamically linked executables to run (Python code using libraries)
programs.nix-ld = {
enable = true;
libraries = options.programs.nix-ld.libraries.default ++ (
with pkgs; [
cairo
dbus
dbus-glib
e2fsprogs
flac
fontconfig
freetype
fuse
glib
gtk2
gtk3
libelf
libGL
libjpeg
libogg
libpng
libpq
libtiff
libva
libvorbis
libxkbcommon
pipewire
wayland
]
);
};
Read: You can’t mix and match NixOS system packages and Python packages installed from PyPI. Choose either the NixOS or the Python way. nix-ld
allows you to stick with the latter.
Learning Nix(OS)
I fully agree and can confirm from personal experience. After embracing the Nix language NixOS configurations started to make sense all of a sudden!
I’ve written a blog post to explain Nix for people with a background from imperative languages, which you may find helpful. It includes links back to the official Nix documentation. Enjoy!