Haskell ghc-9.4.4 flake extra dependencies

I have be trying to build haskell-gi packages in a flake. Things
seemed to be working fine up until today,

There seems to be extra dependencies, so I end up doing things like

 gi-gio =
    let gi-gio-t =
       addPkgconfigDepend osuper.gi-gio super.pcre2;
     in addExtraLibraries gi-gio-t [
       super.util-linux
       super.libselinux
       super.libsepol
       super.pcre
     ];

which works.

But suddenly with gi-gdkpixbuf I get a dependency on libdeflate, which doesn’t have a libdeflate.pc, so I cant just add it as a dependency. What normally happens is that the depency on libtiff which includes the -ldeflate
in its dependencies. However now pkgconfig seems to wants the file to exist. Is there a way to removePkgconfigDepend it so that the build driver doesn’t complain and stop the build. There is no reason for the build to fail.

The libtiff and gdk-pixbuf packages build fine, and I don’t see any need for all these overrides when I build with ghc-9.2.5, so it seem to be a ghc-9.4.4 issue.

Why is this going on?

1 Like

Do you have a github repo that can reproduce the problem you’re seeing? Ideally just in a single default.nix file (not using flakes at all)?

I fixed my problem by overlaying the libdeflate derivation with
one that generated a libdeflate.pc file.

The issue that bothered me was having toaddExtraLibraries all the indirect dependencies that previously were handled in ghc-9.4 builds up to a few days ago, and still seem to work with ghc-9.2.

I was just checking that there wasn’t some basic change to the Haskell (or other) infrastructure that I wasn’t aware of.

If I do a:

nix-build '<nixpkgs>' -A pkgs.haskell.packages.ghc925.gi-gdkpixbuf

things run just fine. But doing a:

nix-build '<nixpkgs>' -A pkgs.haskell.packages.ghc944.gi-gdkpixbuf

will error out with:

error: builder for '/nix/store/7nrzad87ajjlark9spab4lhxnbnfy55d-haskell-gi-base-0.26.3.drv' failed with exit code 1;
       last 10 log lines:
       > Dependency gobject-2.0 >=2.42: using version 2.74.3
       > Dependency glib-2.0: using version 2.74.3
       > Error: Setup:
       > '/nix/store/5cip8xpjb9g10nwyzyslxpck3anc4r4h-pkg-config-wrapper-0.29.2/bin/pkg-config'
       > exited with an error:
       > Package libpcre2-8 was not found in the pkg-config search path.
       > Perhaps you should add the directory containing `libpcre2-8.pc'
       > to the PKG_CONFIG_PATH environment variable
       > Package 'libpcre2-8', required by 'glib-2.0', not found
       >
       For full logs, run 'nix log /nix/store/7nrzad87ajjlark9spab4lhxnbnfy55d-haskell-gi-base-0.26.3.drv'.
error: 1 dependencies of derivation '/nix/store/0ryc3d5zyjqkfcfdqsvsdl2qh7mhzfnm-gi-gdkpixbuf-2.0.29.drv' failed to build

Leading to a long chain of additions seen in my previous post.

Hey @barryfm I’m seeing the same issue. Any chance you could post your resolution?

I wonder if this is caused by

I can show you the overlay I use currently to build my packages for ghc94x from nixpkgs-unstable. Its basically a compose.__CabalEagerPkgConfigWorkaround anything
that shows pkg-config problems.

self: super:
let myghc =
      if super.haskell.compiler ? "ghc946" then "ghc946" else
      if super.haskell.compiler ? "ghc945" then "ghc945" else
      "ghc944";
    mypostgresql = (if super ? "postgresql_16"
                    then super.postgresql_16
                    else super.postgresql_15);
in
rec {
  #myHaskellPackages = let h-srcs = /proj/barry/src/haskell; in
  myHaskellPackages = let h-srcs = ../haskell; in
    self.haskell.packages.${myghc}.override {
      overrides = oself: osuper: with super.haskell.lib;
      let fixCabal = compose.__CabalEagerPkgConfigWorkaround;
      in rec {
        ## ListLike checks just takes too long)
        #ListLike = dontCheck osuper.ListLike;

        ## Newer versions

        #ghc-lib            = osuper.ghc-lib_9_4_4_20221225;
        #ghc-lib-parser     = osuper.ghc-lib-parser_9_4_4_20221225;
        #ghc-lib-parser-ex  = osuper.ghc-lib-parser-ex_9_4_0_0;

        microlens          = osuper.microlens_0_4_13_1;
        microlens-ghc      = osuper.microlens-ghc_0_4_14_1;
        microlens-platform = osuper.microlens-platform_0_4_3_3;

        fgl                = osuper.fgl_5_8_1_1;
        #http-api-data      = osuper.http-api-data_0_5_1;
        #attoparsec-iso8601 = osuper.attoparsec-iso8601_1_1_0_0;
        postgresql-simple  = osuper.postgresql-simple_0_6_5;
        #hlint              = osuper.hlint_3_5;
        #ormolu             = osuper.ormolu_0_5_3_0;
        #stylish-haskell    = osuper.stylish-haskell_0_14_4_0;

        ## Jailbreaks
        ShellCheck     = dontCheck (doJailbreak osuper.ShellCheck);
        Chart          = doJailbreak osuper.Chart;
        string-qq      = doJailbreak osuper.string-qq;
        hslua-aeson    = doJailbreak osuper.hslua-aeson;
        pandoc         = doJailbreak osuper.pandoc;
        OpenGLRaw      = doJailbreak osuper.OpenGLRaw;

        ## Dependency fixes for ghc-9.4.x

        haskell-gi-base = fixCabal osuper.haskell-gi-base;
        haskell-gi      = fixCabal osuper.haskell-gi;
        gi-glib         = fixCabal osuper.gi-glib;
        gi-gmodule      = fixCabal osuper.gi-gmodule;
        gi-gobject      = fixCabal osuper.gi-gobject;
        gi-atk          = fixCabal osuper.gi-atk;
        gi-harfbuzz     = fixCabal osuper.gi-harfbuzz;
        gi-gio          = fixCabal osuper.gi-gio;
        gi-gdkpixbuf    = fixCabal osuper.gi-gdkpixbuf;
        gi-pango        = fixCabal osuper.gi-pango;
        gi-gdk          = fixCabal osuper.gi-gdk;
        gi-gtk          = fixCabal osuper.gi-gtk;
        gi-cairo        = fixCabal osuper.gi-cairo;
        gi-cairo-render = fixCabal osuper.gi-cairo-render;

        ## Standard setup
        postgresql-libpq = osuper.postgresql-libpq.override {
          postgresql = mypostgresql;
        };

        ## Own code
        ecube = osuper.callPackage (h-srcs + /ecube-lib) {};
        ecube-apps-cli = osuper.callPackage (h-srcs + /ecube-apps/cli) {};

        gi-chart-cairo = osuper.callPackage (h-srcs + /chart-backends/gi/gi-chart-cairo) { inherit (super) cairo; inherit (super) pcre2; };
        gi-chart-gtk = osuper.callPackage (h-srcs + /chart-backends/gi/gi-chart-gtk) {};
        ecube-apps-gi = osuper.callPackage (h-srcs + /ecube-apps/gi-gtk) {};
        ecube-new = osuper.callPackage (h-srcs + /ecube-new) {};
      };
    };

  myHaskellEnv = self.haskell.packages.${myghc}.ghcWithPackages
    (haskellPackages: with self.myHaskellPackages; [
      ## base libraries
      base bytestring colour data-default-class
      deepseq directory filepath
      lens mtl parsec time unix
      aeson formatting

      ## build dependencies
      ## (so it they get garbage collected and force rebuilds)
      hspec path hscolour

      ## used by programs
      Decimal
      GLUT
      Glob
      HTTP
      ansi-terminal
      cassava
      cryptonite
      data-ordlist
      fsnotify
      #hsshellscript  ## Broken in ghc943
      http-conduit
      posix-paths
      postgresql-simple
      regex-pcre
      regex-tdfa
      split
      sqlite-simple
      strict
      utility-ht
      xdg-basedir
      xml

      ## Trying out (not yet used)
      selective
      witch

      ## tools
      ShellCheck
      alex
      c2hs
      cabal-install
      cabal2nix
      happy
      hasktags
      hlint
      hoogle shake
      hpack
      nix-diff
      ormolu
      pandoc

      ## own cli
      Chart
      ecube
      ecube-apps-cli
      ecube-new

      ## haskell-gi
      haskell-gi
      gi-cairo gi-cairo-render gi-cairo-connector
      gi-gdk gi-gtk gi-gtk-hs

      ## own gtk
      gi-chart-gtk gi-chart-cairo
      ecube-apps-gi

      ## Was Seperately installed
      #ghcid  ## Still doesn't install executable
      ghcide
      #haskell-language-server
      stylish-haskell
    ]);
  };
}
1 Like

Upstream issue for reference: Cabal 3.8 expects `pkg-config --libs --static` to always work. · Issue #8455 · haskell/cabal · GitHub. Cabal would be interested in a fix for this, but seems like no one is working on it at the moment. Would be great to have this fixed for 3.12 at least, it’s too late for 3.10 already…