Despite the similar name nix shell
, is something completely different from nix-shell
– unlike the older nix-shell
command, it won’t run the setup hooks that set the environment variables. See e.g. Using `nix run` with several packages - #3 by jtojnar or Flakes: how to make `pkg-config` work with `nix shell`? - #2 by sternenseemann
mkDerivation
and similar helpers like buildPythonPackage
will run the setup hooks listed in inputs, which will make the environment variables available at build time but it is your responsibility to ensure they are available at runtime.
You can achieve that by using a wrapper.