Explanation why python still finds binaries invisible from pure nix-shell

With this shell.nix

let
  nixpkgs = fetchTarball "https://github.com/NixOS/nixpkgs/tarball/nixos-24.11";
  pkgs = import nixpkgs { config = {}; overlays = []; };
in   pkgs.mkShellNoCC {
  packages = with pkgs; [
    (pkgs.python311.withPackages (
      pythonPackageSet:
      builtins.attrValues { 
        inherit (pythonPackageSet)
          jupyterlab
          # jupyterlab-git
          ;
      }
    ))
  ];
}

when nix-shell --pure git is not found as expected, can someone explain why in a python a git installed outside of nix-shell pure scope still is found ? Background: I want to check if an extra binary is contained in a set as in that example or if it is already provided with the python package itself:

[user:~/nix-python-shell]$ nix-shell --pure
[nix-shell:~/nix-python-shell]$ python
>>> import os
>>> os.system(r'"git"')
# or even when jupyterlab-git in shell.nix
>>> from jupyterlab_git.git import Git
>>> Git().status('~/.nix-config')
1 Like

Most likely python evaluates some global rcfile, since it doesn’t care what args the shell nix executed has. Very annoying behavior, though.

1 Like