Propagating test dependencies to end users

This week a friend asked an intriguing question on Twitter

Why does nixpkgs.python39Packages.python-lsp-server depend on freaking QT?

I looked into it’s default.nix in nixpkgs, and it comes through pyqt:

code

nixpkgs/default.nix at 73ad5f9e147c0d2a2061f1d4bd91e05078dc0b58 · NixOS/nixpkgs · GitHub

The LSP server only uses pyqt as a test requirement: python-lsp-server/setup.cfg at 552dea39cd6bb4d51c2cf144ab1b57748042b8fc · python-lsp/python-lsp-server · GitHub

So the question is - is this by design and does it make sense? It should be a part of a build process (test deps), but it’s not required for python-lsp-server to run and I wouldn’t expect it to be downloaded unless you’re building the package from scratch (i.e. a cache hit).

I’m a bit inexperienced with combining buildPythonPackage w/ buildInputs and nativeBuildInputs. As far as I understand, this should be a part of nativeBuildInputs and not buildInputs.

I don’t see the issue. It is added as test input (checkInputs) which means it is only used during build time when tests are enabled. There is no runtime dependency.

$ nix why-depends nixpkgs#python3.pkgs.python-lsp-server nixpkgs#python3.pkgs.pyqt5
these 5 paths will be fetched (15.68 MiB download, 74.85 MiB unpacked):
  /nix/store/3k9xwlmq4l6r20wzzwc0ls9l00p73rg5-qtwebchannel-5.15.3
  /nix/store/6j6pj3yjfbvl2a72ql21x4r51jr0k4sm-qtdeclarative-5.15.3
  /nix/store/8dm7k0v2rm2bj1f91hacmha2bp3b1sqw-qtsvg-5.15.3
  /nix/store/rplfm52hjqixy0axjnv0cvvjr22wfzcw-qtbase-5.15.3
  /nix/store/sgl0171sagjx58am4vxsb6z1jiy2lhny-python3.9-PyQt5-5.15.4
'/nix/store/f7qgpp9mq9sgp1nywl9cc176m874mf7j-python3.9-python-lsp-server-1.3.3' does not depend on '/nix/store/sgl0171sagjx58am4vxsb6z1jiy2lhny-python3.9-PyQt5-5.15.4'
1 Like

Thank you, that’s it! Wasn’t aware that checkInputs is a general flag and not a part of buildPythonPackage
https://nixos.org/manual/nixpkgs/stable/#ssec-check-phase