I generally avoid python globally unless u might need it for other purposes. Coz Python have it’s own ecosystem specific environment management like pip, uv.
So let’s say u want a global python with a dependency as u mentioned above, but it might pollute the environment with it’s own dependencies. So it’s suggested to use python in Nix shells. It’s the same reason reason why people suggest you to use venv whenever u start a project. In nix, u try for a much more pure environments.
It can encourage practices that will tend to cause problems. Python scripts often don’t work with a bare parser like that, even if they would work with something like pkgs.writers.writePython3 with the same libraries declared. This is because the machinery of an actual stdenv derivation is doing more in the background than a bare parser, propagating necessary binary artifacts and other environmental dependencies is one major part.
If you can convince someone not to do this, and run python entirely from dev shells, as part of packaged scripts, or with nix-shell shebangs, they’ll likely have less frustration later.
I was not aware of the pkgs.writers feature! It would look a bit overkill to call a writePython3 and adapt the makeWrapperArgs for each script.
Assuming the user wants to have a bunch of scripts in their PATH, using nix-shell shebangs appears to be the simplest and most straightforward approach. However, this would require the user to tweak their scripts.
If the user’s scripts do not have dependency conflicts (big assumption in the long run), it might be possible to bundle all of them into a single derivation where the runtime dependencies are specified. Are you aware of any helpers or examples for doing this?
There is nothing wrong with installing a python interpreter globally. I think the Wiki is wrong.
What else am I supposed to use as a command line calculator?
It’s just in many cases better to have project specific development or runtime environments.
edit: You all are missing the point. There is nothing wrong with installing Python.
There are a lot of terminal based calculators, though personally I prefer to fire up a REPL of whatever language I feel happy with through a nix-shell -p
If a Python interpreter and third-party Python modules aren’t installed via configuration.nix, doesn’t that mean that running nix-shell -p python3 pypackage1 pypackage2 ... is more likely to download those packages, because they wouldn’t already be in the Nix store?
That could be a problem for scripts that use nix-shell shebangs.
nix-shell shebangs are most useful for developing the script itself. For exactly the reason you brought up, I recommend packaging the scripts for day-to-day use.