Yes you need to use a shell to make it reproducible in the nix sense; a regular venv will try to point to the nix store or lose libraries (or try to dynamic-link stuff) when your system env changes which is why you need it to be independent of it.
I don’t bother with venvs in my own projects because nix kind of subsumes its purpose, but it’s possible to work with them still.
Something that might help: devenv. I haven’t used this personally but the UX looks like an upgrade. (I just use flakes with dev shells defined inline long-form)
If you don’t use a venv at all, do you add every new requirement to your main config.nix?
If it matters, I’m not a real developer. I don’t deploy or package anything. I’m just making tools for my own work. I’m not concerned about Nix-like reproducibility for my python scripts because they’re pretty simple and only live on my machine.
No, not to my nixos configuration. In fact I don’t even have a global / system / user-wide Python interpreter. I rely on nix shells and package closures; no imperative use of python.
I’m not a big python dev; my meaningful experience is with systems languages. But for a release or project i intend to be consumed outside of nix, I’ll use venvs and a requirements file because that’s just the right way to do things.
But what I meant was that I’d use a nix shell or build package that uses py libs that are already packaged for nix, or package the ones that aren’t myself, and just use the nix closure as my venv; no regular venv or pip workflow.
Devenv seems to let you just point at a requirements file and it builds the venv for you. Very clean for portability beyond nix consumers that way. But most of my Python projects are personal utilities and can target nix exclusively.
Yes you need to use a shell to make it reproducible in the nix sense; a regular venv will try to point to the nix store or lose libraries (or try to dynamic-link stuff) when your system env changes which is why you need it to be independent of it.
I don’t bother with venvs in my own projects because nix kind of subsumes its purpose, but it’s possible to work with them still.
Something that might help: devenv. I haven’t used this personally but the UX looks like an upgrade. (I just use flakes with dev shells defined inline long-form)
This video came across my feed last night, and might give you a rough idea: https://youtu.be/jldArhyi6jM&t=581
If you don’t use a venv at all, do you add every new requirement to your main config.nix?
If it matters, I’m not a real developer. I don’t deploy or package anything. I’m just making tools for my own work. I’m not concerned about Nix-like reproducibility for my python scripts because they’re pretty simple and only live on my machine.
No, not to my nixos configuration. In fact I don’t even have a global / system / user-wide Python interpreter. I rely on nix shells and package closures; no imperative use of python.
I’m not a big python dev; my meaningful experience is with systems languages. But for a release or project i intend to be consumed outside of nix, I’ll use venvs and a requirements file because that’s just the right way to do things.
But what I meant was that I’d use a nix shell or build package that uses py libs that are already packaged for nix, or package the ones that aren’t myself, and just use the nix closure as my venv; no regular venv or pip workflow.
Devenv seems to let you just point at a requirements file and it builds the venv for you. Very clean for portability beyond nix consumers that way. But most of my Python projects are personal utilities and can target nix exclusively.