on iko/ghcjs-patch-master help sign in
Fix propagation of pkgconfig and frameworks (#715)

pkgconfig-depends that make use of propagatedBuildInputs and frameworks are not propagated to the exe component that links them. This seems to be because our libraries do not not include their dependencies as `buildInputs`. To make this work it also seems to be necessary for pkgconfig depends themselves to be `propagaedBuildInputs`.

commit9c6eb16428e491d10978fda6b4b459d59b220a11 authorHamish Mackenzie <Hamish.Mackenzie@iohk.io> dateSun 21 Jun 2020, 16:40 (6 years ago) parent4cf7a55
4 files changed+16−7
builder/comp-builder.nix+7−5 builder/hspkg-builder.nix+1 builder/shell-for.nix+7−1 package-set.nix+1−1
builder/comp-builder.nix+7−5
@@ -215,12 +215,14 @@ stdenv.mkDerivation ({
215215
216216 enableParallelBuilding = true;
217217
218+ propagatedBuildInputs =
219+ frameworks # Frameworks will be needed at link time
220+ # Not sure why pkgconfig needs to be propagatedBuildInputs but
221+ # for gi-gtk-hs it seems to help.
222+ ++ builtins.concatLists pkgconfig;
223+
218224 buildInputs = component.libs
219− ++ frameworks
220− ++ builtins.concatLists pkgconfig
221− # Note: This is a hack until we can fix properly. See:
222− # https://github.com/haskell-gi/haskell-gi/issues/226
223− ++ lib.optional (lib.strings.hasPrefix "gi-" fullName) gobject-introspection;
225+ ++ map (d: d.components.library or d) component.depends;
224226
225227 nativeBuildInputs =
226228 [shellWrappers buildPackages.removeReferencesTo]
builder/hspkg-builder.nix+1
@@ -84,6 +84,7 @@ let
8484 component = components.setup // {
8585 depends = config.setup-depends ++ components.setup.depends ++ package.setup-depends;
8686 extraSrcFiles = components.setup.extraSrcFiles ++ [ "Setup.hs" "Setup.lhs" ];
87+ pkgconfig = if components ? library then components.library.pkgconfig or [] else [];
8788 };
8889 inherit package name src flags revision patches defaultSetupSrc;
8990 inherit (pkg) preUnpack postUnpack;
builder/shell-for.nix+7−1
@@ -28,6 +28,12 @@ let
2828 # because cabal will end up ignoring that built version;
2929 removeSelected = lib.filter
3030 (input: lib.all (cfg: (input.identifier or null) != cfg.identifier) selected);
31+ # Also since a will include the library component of b in its buildInputs
32+ # (to make `propagatedBuildInputs` of `pkgconfig-depends` work) those should
33+ # also be excluded (the pkgconfig depends of b will still be included in the
34+ # system shells buildInputs via b's own buildInputs).
35+ removeSelectedInputs = lib.filter
36+ (input: lib.all (cfg: input != cfg.components.library or null) selected);
3137
3238 packageInputs = removeSelected
3339 (lib.concatMap (cfg: cfg.depends) selectedConfigs
@@ -37,7 +43,7 @@ let
3743
3844 # Add the system libraries and build tools of the selected haskell
3945 # packages to the shell.
40− systemInputs = lib.concatMap (p: p.components.all.buildInputs) selected;
46+ systemInputs = removeSelectedInputs (lib.concatMap (p: p.components.all.buildInputs) selected);
4147 nativeBuildInputs = removeSelected
4248 (lib.concatMap (p: p.components.all.executableToolDepends) selected);
4349
package-set.nix+1−1
@@ -13,7 +13,7 @@ in pkgs.lib.evalModules {
1313 # as well as pkgconfPkgs, which are used to resolve pkgconfig name to nixpkgs names. We simply
1414 # augment the existing pkgs set with the specific mappings:
1515 pkgs = pkgs // (import ./lib/system-nixpkgs-map.nix pkgs);
16− pkgconfPkgs = pkgs // (import ./lib/pkgconf-nixpkgs-map.nix pkgs);
16+ pkgconfPkgs = import ./lib/pkgconf-nixpkgs-map.nix pkgs;
1717
1818 inherit buildModules;
1919 };