Derivation: Unexpected Python package exclusion on adding Mercurial


I adapted the following derivation to create a Python + PyQt environment via default.nix:

with import <nixpkgs> {};
stdenv.mkDerivation rec {
  name = "env";

  env = buildEnv { name = name; paths = buildInputs; };
  builder = builtins.toFile "" ''
    source $stdenv/setup; ln -s $env $out

  # Customizable development requirements
  buildInputs = [ wget git qt5.qtwayland

    # With Python configuration requiring a special wrapper
    (python37.buildEnv.override {
      #ignoreCollisions = true;
      ignoreCollisions = false;
      extraLibs = with python37Packages; [ pyqt5 inflect ];

  shellHook = ''
    export QT_QPA_PLATFORM=wayland

It works as I’d want. I can run a Python PyQt example. However, there’s a niggle. I use mercurial for local source control, so I’d like to include mercurial in my buildInputs list. If I do, like so:

buildInputs = [ wget mercurial git qt5.qtwayland

the derivation appears to build without error. Python is present after the fact, as is git, mercurial and wget. However, the python libraries, PyQt5 and inflect, are no longer findable.

If I remove mercurial from buildInputs, the libraries reappear, and my Python test code obligingly pops up a window. This is only true for mercurial; I can add/remove other packages (like git and wget) without issue.

Additionally, if I add mercurial via ‘nix-env -i mercurial’ (and not via default.nix, the libraries are there, and the test works.

I’m new to NiXOS, and I’d appreciate any guidance you could offer.