Project setup
Since switching to NixOS, its declarative nature means PATH resolution works differently from a standard Linux setup.
Consequently, it's been a headache to use Python packages like Jupyter notebooks (which require a persistent kernel), or to get the most up-to-date packages that UV fetches from PyPI.
So naturally, when I found a solution that auto-activates my project environment, creates a persistent kernel within, and sorts out all the pathing issues — all while getting the latest updates using UV — it made sense.
It's also eye-wateringly simple.
Devenv
Honestly, if you want to skip this entirely and see the official documentation, I don't blame you: click here.
Devenv is a "fast, declarative, reproducible and composable developer environment using Nix."
I'm only 8 months into my coding journey, so I have no idea how it handles services and containers. But it's instant — the cache is auto-invalidated when any tracked file changes.
For my learning curve as a data analyst, it also permits some neat auto-activation:
- In my bash:
# auto-activate devenv on projects when CD into them
eval "$(devenv hook bash)"
- Activating my UV environment:
{ pkgs, lib, config, inputs, ... }: {
languages.python = {
enable = true;
venv.enable = true;
uv = {
enable = true;
sync.enable = true;
};
};
}
Sprinkle in something like Primeagen's tmux-sessionizer and you reduce so many commands to just one:
- immediately goes to my project directory
- activates devenv (deactivates on exit)
- activates venv
- add whatever else
All under Ctrl+s (in my case), start typing whatever the project's called.
These tools save so much time and headache.
So what's the big deal?
Other than the speed of environment setup allowing me to learn faster, it also permits the latest updates — I get to use pip/UV.
As mentioned previously, PyPI is the most up-to-date Python package index, so any deviation from it, such as the NixOS store, wouldn't permit the most up-to-date packages.
As of writing, Pandas 3.0.3 has been out since January.
The NixOS store is 6 months behind.
Devenv also stops the headache of package binary issues, since PATH resolution is different on NixOS for certain binaries. Devenv solves this.
Honestly, I'm not entirely sure how Devenv works still. But it's perfect for what I need.
The slight downside I've seen so far (it's not a problem at all)
There's a lot of setup files:
../
.devenv/
.git/
.ipynb_checkpoints/
.gitignore
.python-version
README.md
Untitled.ipynb
devenv.lock
devenv.nix
devenv.yaml
main.py
pyproject.toml
uv.lock
Only .devenv/ is gitignored — the config files (devenv.*, pyproject.toml, uv.lock) are committed to the repo. That's the whole point: anyone can clone it, run devenv shell, and have the exact same environment. They can also use uv/pip - which was something I always wanted in my public projects.
Moving forward
I'm in the process of starting my third project, which will handle messy data, clean it, and use some advanced statistics to convey a story.
I will most certainly be using Devenv for this and future projects.
I highly recommend Nix users consider it.