Is it possible to install python such that pip works as it would on any other linux system?
When I try to install pip by running python -m ensurepip --upgrade it errors with:
error: externally-managed-environment
× This environment is externally managed
╰─> This command has been disabled as it tries to modify the immutable
`/nix/store` filesystem.
To use Python with Nix and nixpkgs, have a look at the online documentation:
<https://nixos.org/manual/nixpkgs/stable/#python>.
The manual has lots of information on how to use pip to build packages and for that matter the declarative immutable way nixos does things is really helpful. However I just wanna play around with it in my user environment, as I would on any other linux machine without having to rebuild my system for each pip package I need.
Is it possible to use pip and other related python technologies in userspace mutably?
No, I do not want to develop a project or configure a separate environment of some sorts. I need to use pip as someone would when installing it on i.e. archlinux.
When developing actual projects I use uv.
My actual problem is that a kde plasma plugin needs several python packages to be installed globally to run. Right now I am installing each one manually using my system config and then I have to reboot my PC (or at least relaunch my desktop environment) for the plugin to be able to access the packages, which takes around 5 minutes each time, plus I have to relaunch all applications, after which I can reload the plugin, click around in it a bit and then have it crash and open it’s log file to search for the next package that was missing.
Being able to just do pip install foobar would be really helpful.
It’s also a more general thing I encountered when using stuff that depends on python. Sometimes random tools and projects expect python or pip to be installed globally and want to execute it themselves. Which is obviously not how NixOS does things, but sometimes it is convenient to have things work the way they do everywhere else for less friction when trying out new stuff.
For most stuff in Desktop NixOS in general I found that I am way more productive when I install the mutable version to try it out and then later switch to the nix-ified version when I know what I want.
I think your best bet is to just create the derivations for those scripts, maybe applying patches to ensure all the required PyPI packages are installed.
Having random scripts run pip install is janky anyway, not to mention a potential gaping security hole, since anyone can upload anything to PyPI.