Libxml not found with dependent build

I am creating my first nix-package and I ran into an issue, my current code is in this branch:

I’ve extended the mlt package to optionally build python-bindings and then created a python3Packages.mlt-bindings package which installs the bindings. My issue is that, for whatever reason, when I do (NIXPKGS just contains the path of my local nixpkgs root folder):

nix build -L --show-trace $NIXPKGS#mlt, the libxml2-package is found by the build scripts:

mlt> Configuring modules/xml:
mlt> Configuring mlt++:

However, when I instead build the mlt-bindings:

nix build -L --show-trace $NIXPKGS#python3Packages.mlt-bindings

they are not found:

mlt> Configuring modules/xml:
mlt> - xml2 not found: disabling xml module
mlt> Configuring mlt++:

The configure script runs pkg-config libxml-2.0 > /dev/null 2>&1 and I fail to see how building the mlt-bindings changes how mlt itself is build.

Could someone with more Nix experience please point me in the right direction here?

One difference I’ve just found comparing the .drv-files used to build mlt is:

/nix/store/qld2py1i5hh2g2kp3mjpfhbfy9s2r3wv-libxml2-2.9.12-py when building python3Packages.mlt-bindings vs
/nix/store/23lxa5wj1vklkhfkv6p7zhdrr8ha5s9l-libxml2-2.9.12-dev when building mlt directly

Changing the libxml2 dependency explicitely to libxml2.dev in the mlt derivation seems to do the trick. Still, could someone enlighten me what is going on here and if this is the correct thing to do?

Still, could someone enlighten me what is going on here

pkgs-config looks for a .pc to get information about the related package, this file is located in the .dev. Since libxml2’s default output is the “bin” output, it’s probably not getting the out/dev pairing that you would expect for most libraries, thus .dev needs to be explicitly referenced.

$ nix-build -A libxml2
/nix/store/yz1mc085klri4wn282gpwg8drkwm002c-libxml2-2.9.12-bin
$ ls $(nix-build -A libxml2.dev)/lib/pkgconfig
libxml-2.0.pc

If libxml2 as a buildInput doesn’t work, then what you did with .dev as a nativeBuildInputs should work.

Thanks for responding. What I still haven’t understood is how building a different derivation influences how one of its dependencies is built.

nix show-derivation $NIXPKGS#mlt

"inputDrvs": {
  ...
      "/nix/store/5lpa1gxq20l0ik38yrj29hq7b09zp390-libxml2-2.9.12.drv": [
        "dev"
      ],
},

So just building mlt correctly selects the dev output. Building the Python bindings however:

nix show-derivation $NIXPKGS#python3Packages.mlt-bindings

    "inputDrvs": {
      "/nix/store/kgrz085s53prgdlh2l93najgcws59mcx-mlt-6.26.0.drv": [
        "out"
      ],

Finally: nix show-derivation /nix/store/kgrz085s53prgdlh2l93najgcws59mcx-mlt-6.26.0.drv

    "inputDrvs": {
      "/nix/store/5lpa1gxq20l0ik38yrj29hq7b09zp390-libxml2-2.9.12.drv": [
        "py"
      ],

dev has changed to py for the mlt-derivation.

Python package set contains a different libxml2 package (pointing specifically to the py output). If you use its callPackage as you have done:

then the package will be passed arguments from there.

Instead, you should create mlt python module using .override like e.g. avahi does:

2 Likes

Many thanks jtojnar, that explains it.