How to break nix cyclic dependency?

I am trying to build the libuv manpage and install it as a different output.
To build the manpage it needs sphinx (from python) but if I include it, then I get a cyclic dependency as sphinx requires cython that requires gdb (?!) which in turns pulls in cmake that relies on libuv (at least when useSharedLibraries is set) !

error: while evaluating the attribute 'nativeBuildInputs' of the derivation 'libuv-1.33.1' at /home/teto/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:191:11:
while evaluating the attribute 'out.outPath' at /home/teto/nixpkgs/lib/customisation.nix:151:13:
while evaluating the attribute 'propagatedBuildInputs' of the derivation 'python3.7-sphinx-2.2.0' at /home/teto/nixpkgs/pkgs/development/interpreters/python/mk-python-derivation.nix:102:3:
while evaluating the attribute 'out.outPath' at /home/teto/nixpkgs/lib/customisation.nix:151:13:
while evaluating the attribute 'propagatedBuildInputs' of the derivation 'python3.7-snowballstemmer-2.0.0' at /home/teto/nixpkgs/pkgs/development/interpreters/python/mk-python-derivation.nix:102:3:
while evaluating the attribute 'out.outPath' at /home/teto/nixpkgs/lib/customisation.nix:151:13:
while evaluating the attribute 'nativeBuildInputs' of the derivation 'python3.7-PyStemmer-1.3.0' at /home/teto/nixpkgs/pkgs/development/interpreters/python/mk-python-derivation.nix:102:3:
while evaluating the attribute 'out.outPath' at /home/teto/nixpkgs/lib/customisation.nix:151:13:
while evaluating the attribute 'buildInputs' of the derivation 'python3.7-Cython-0.29.14' at /home/teto/nixpkgs/pkgs/development/interpreters/python/mk-python-derivation.nix:102:3:
while evaluating the attribute 'buildInputs' of the derivation 'gdb-8.3.1' at /home/teto/nixpkgs/pkgs/development/tools/misc/gdb/default.nix:27:3:
while evaluating the attribute 'nativeBuildInputs' of the derivation 'libipt-2.0.1' at /home/teto/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:191:11:
while evaluating the attribute 'buildInputs' of the derivation 'cmake-3.15.5' at /home/teto/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:191:11:
infinite recursion encountered, at undefined position

My solution would be to change cmake in the global set to build with useSharedLibraries set to false. Not sure how to do that though.

The best solution would be to find an invalid link and fix it (like cython → gdb).

As this may not be feasible, another option is to build cython with a different version of cmake with ‘isBootstrap’ set to true. See stage1 in pkgs/stdenv/darwin/default.nix

Another option would be to build the documentation in a separate derivation. The two derivations could be re-unified later on if needed with a fake multi-output derivation.

1 Like