How to hide a global pkgs inside a nix shell? (edit: miss match of ghcide version inside nix shell)

[nataneb@nixos:~/haskell-practice/discord-bot]$ whereis ghcide
ghcide: /nix/store/l7ncb0skqzy12kqy3phr3812cywzw0j0-ghc-9.0.1-with-packages/bin/ghcide /nix/store/2lkk8iw148b991mrp15as76hjkj607iq-ghcide-1.4.2.3/bin/ghcide

So i have two binaries pointing to the same command. But i just want this (/nix/store/l7ncb0skqzy12kqy3phr3812cywzw0j0-ghc-9.0.1-with-packages/bin/ghcide). How can i hide the later inside a nix shell?

I have xmonad installed. Because of that i have another ghc in my global conf.

Binaries in PATH inside the shell will usually take precedence over the binaries outside. If you want to clear the outside environment including PATH to be absolutely sure, use the --pure flag.

I see. So there is something wrong inside my emacs config

Actually the problem was on my mkShell. I was trying to use pkgs.haskell.packages.ghc901 with pkgs.haskellPackages.haskell-language-server. The fix was replace the with pkgs.haskellPackages for with pkgs.haskell.packages.ghc901

Does that flag exist for nix shell/nix develop? Can you set it declaratively?

--ignore-environment / -i, not possible to set declaratively, since derivations aren’t really concerning themselves with development environment, so handling such things there would be a layer violation, imo. mkShell is basically just a hack to create fake derivations that can act as a development environment easily.