cabal2nix icon indicating copy to clipboard operation
cabal2nix copied to clipboard

Adding pkgconfig-depends: hdf5 pulls in Haskell's hdf5, not system hdf5

Open pmiddend opened this issue 1 year ago • 6 comments

I have basically the following in my .cabal file (full repo):

executable bla
  main-is: Main.hs
  hs-source-dirs:
      app
  build-depends:
      base >=4.7 && <5

  pkgconfig-depends: hdf5

Note I don't want to have hs-hdf5 in my package, because that's broken in nixpkgs. I want to use nixpkgs.hdf5 and build the bindings myself.

However, the derivation cabal2nix generates includes hdf5 as an input argument, and that resolves to haskellPackages.hdf5.

I was able to fix this weird situation by doing:

          haskellPackages = pkgs.haskellPackages.override
            {
                hdf5 = super.text;
              };
            };

But for hopefully obvious reasons, this is not a good solution.

Any way out of this?

pmiddend avatar Jul 10 '24 08:07 pmiddend

Just add inherit (pkgs) hdf5; to the attrSet your passing to callCabal2nix in line 68.

maralorn avatar Jul 10 '24 08:07 maralorn

Just add inherit (pkgs) hdf5; to the attrSet your passing to callCabal2nix in line 68.

Ah, thanks, that works!

But I'm not sure if we should close the issue now. I do see this as a bug. Specifying pkgconfig-depends should not lead to any Haskell packages being included suddenly.

pmiddend avatar Jul 10 '24 11:07 pmiddend

This falls certainly into the "works as intended category".

I think everyone who learns about this is annoyed by it (at least in the beginning.)

This is caused by conventions in nixpkgs which have to do with making overriding and cross-compilation work.

It seems like a reasonable feature request to make this better, but I don’t see a solution without breaking other things.

maralorn avatar Jul 10 '24 11:07 maralorn

And something along the lines of "don't take haskellLib, mylib as derivation parameter", but just haskellPackages and mylib and then getting the Haskell dependencies from haskellPackages.foobar doesn't work?

pmiddend avatar Jul 10 '24 11:07 pmiddend

It would break overriding of haskell packages.

maralorn avatar Jul 10 '24 11:07 maralorn

I see. Thanks for your responses, that has been very helpful. :)

pmiddend avatar Jul 10 '24 11:07 pmiddend