If you just want to use black, you can skip the withPackages thing, and just use black in your "buildInputs`.
Beyond that, since you say you’re new, I think that wiki entry is doing a few unecessary things:
I don’t think you need to set $PYTHONPATH at all at least from my own usage. That’s kind of the point of withPackages, setting up the python path correctly… The site-packages end up where Python considers its root to be, so they don’t need to be added to the path.
The other thing is that my-python variable. It’s completely superfluous.
Finally, I think the actual issue is this:
{ pkgs ? import <nixpkgs> {} }:
You seem to be using a nix that does flakes things. You’re not allowed to use the <nixpkgs> notation, because it is impure (I.e., the version of nixpkgs that points to depends on the environment the command runs in), and therefore prohibited by a flaky nix.
--show-trace will probably give you a nicer error.
I’m unsure why this would leak into nix-shell, which principally shouldn’t be complaining about that, but that’s what the error you’re getting refers to. It’s been a while since I used non-flake shells, but I think you can simply remove the ? import <nixpkgs> {} bit and it should work.
Your nix version is very new, considering that 2.4 released a week or two ago, is there any reason you’re using a version that recent?
Also, If I just simply set up a shell environment without site-packages (I tried Python and R, none of them works) or packages installed system-wide, everything just works.
example shell.nix which works when called `nix-shell:
Update your channels and rebuild your full install
Use --impure
If you need to use --impure, this might be worth raising as a bug against nix, I don’t think nix should be complaining about that path…
Again, any reason you’re using a dev version of nix? I don’t think anyone should be using that, unless they’re testing (in which case you’d probably know how to fix this ) or have a very specific use case.
Flakes, as well as the nix subcommands, are not stable yet, right? Why would nix-shell no longer work under those conditions, is this down to using an unstable version of nix?