From 6d1508d7a2c3ce0b46d114f0584cf610a52c5290 Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone <exarkun@twistedmatrix.com> Date: Tue, 25 Apr 2023 16:28:48 -0400 Subject: [PATCH] A better fix for the zlib build issue Tell cabal to configure zlib a certain way when building it, making its build errors go away without changing our own cabal package configuration. --- cabal.project | 7 +++++++ flake.nix | 1 - gbs-downloader.cabal | 12 +++--------- nix/haskell-packages.nix | 17 +---------------- 4 files changed, 11 insertions(+), 26 deletions(-) diff --git a/cabal.project b/cabal.project index 8ba70ad..7923c75 100644 --- a/cabal.project +++ b/cabal.project @@ -1,3 +1,10 @@ packages: . https://whetstone.private.storage/privatestorage/tahoe-chk/-/archive/0.1.0.0/tahoe-chk-0.1.0.0.tar.gz https://whetstone.private.storage/privatestorage/tahoe-great-black-swamp/-/archive/0.1.0.1/tahoe-great-black-swamp-0.1.0.1.tar.gz + +package zlib + -- Turn on discovery of the underlying zlib using pkg-config. This + -- fixes build failures when the underlying zlib is not in the + -- traditional location but is discoverable with pkg-config. It might + -- break non-pkg-config platforms. + flags: +pkg-config diff --git a/flake.nix b/flake.nix index c0573fb..fd06ef7 100644 --- a/flake.nix +++ b/flake.nix @@ -28,7 +28,6 @@ compilerVersion = ghcVersion; packageName = "gbs-downloader"; hsPkgsOverrides = import ./nix/haskell-packages.nix { - inherit pkgs; haskellLib = pkgs.haskell.lib; }; }; diff --git a/gbs-downloader.cabal b/gbs-downloader.cabal index d247f4e..8d37700 100644 --- a/gbs-downloader.cabal +++ b/gbs-downloader.cabal @@ -75,7 +75,7 @@ library , language -- Modules exported by the library. - exposed-modules: Tahoe.Download + exposed-modules: Tahoe.Download -- Modules included in this library but not exported. -- other-modules: @@ -94,16 +94,10 @@ library , text -- Directories containing source files. - hs-source-dirs: src + hs-source-dirs: src -- Base language which the package is written in. - default-language: Haskell2010 - - -- We don't directly depend on zlib but we transitively depend on it through - -- some Haskell library that (I think) doesn't bother to declare a pkgconfig - -- dependency - so the build fails if zlib isn't in just the right place - -- unless we add this. - pkgconfig-depends: zlib + default-language: Haskell2010 executable gbs-download -- Import common warning flags. diff --git a/nix/haskell-packages.nix b/nix/haskell-packages.nix index 834ddd8..0411c50 100644 --- a/nix/haskell-packages.nix +++ b/nix/haskell-packages.nix @@ -1,23 +1,8 @@ -{ - pkgs, - haskellLib, -}: hfinal: hprev: { +{haskellLib}: hfinal: hprev: { tahoe-chk = hfinal.callPackage ./tahoe-chk.nix {}; tahoe-great-black-swamp = hfinal.callPackage ./tahoe-great-black-swamp.nix {}; # A broken dependency of a tahoe-great-black-swamp executable that we don't # use. Flip the broken bit so we can get a build. language-ecmascript = haskellLib.unmarkBroken hprev.language-ecmascript; - - # hs-flake-utils does a callCabal2nix for us but we can't use it because we - # need to overide an argument. This overlay runs before the hs-flake-utils - # overlay (a mistake?) so we can't even use hprev.gbs-downloader.override - - # we just have to re-do it all ourselves. - gbs-downloader = hfinal.callCabal2nix "gbs-downloader" ../. { - # cabal2nix gives the generated nix expression a `zlib` parameter which is - # then satisfied *from the Haskell package set* because there is a zlib - # package there and it gets precedence over the zlib in the top-level - # package set. Then the build fails because that's not the zlib we want. - inherit (pkgs) zlib; - }; } -- GitLab