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`.
This commit is contained in:
Hamish Mackenzie 2020-06-21 16:40:52 +12:00 committed by GitHub
parent 4cf7a55a2a
commit 9c6eb16428
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 7 deletions

View File

@ -215,12 +215,14 @@ stdenv.mkDerivation ({
enableParallelBuilding = true;
propagatedBuildInputs =
frameworks # Frameworks will be needed at link time
# Not sure why pkgconfig needs to be propagatedBuildInputs but
# for gi-gtk-hs it seems to help.
++ builtins.concatLists pkgconfig;
buildInputs = component.libs
++ frameworks
++ builtins.concatLists pkgconfig
# Note: This is a hack until we can fix properly. See:
# https://github.com/haskell-gi/haskell-gi/issues/226
++ lib.optional (lib.strings.hasPrefix "gi-" fullName) gobject-introspection;
++ map (d: d.components.library or d) component.depends;
nativeBuildInputs =
[shellWrappers buildPackages.removeReferencesTo]

View File

@ -84,6 +84,7 @@ let
component = components.setup // {
depends = config.setup-depends ++ components.setup.depends ++ package.setup-depends;
extraSrcFiles = components.setup.extraSrcFiles ++ [ "Setup.hs" "Setup.lhs" ];
pkgconfig = if components ? library then components.library.pkgconfig or [] else [];
};
inherit package name src flags revision patches defaultSetupSrc;
inherit (pkg) preUnpack postUnpack;

View File

@ -28,6 +28,12 @@ let
# because cabal will end up ignoring that built version;
removeSelected = lib.filter
(input: lib.all (cfg: (input.identifier or null) != cfg.identifier) selected);
# Also since a will include the library component of b in its buildInputs
# (to make `propagatedBuildInputs` of `pkgconfig-depends` work) those should
# also be excluded (the pkgconfig depends of b will still be included in the
# system shells buildInputs via b's own buildInputs).
removeSelectedInputs = lib.filter
(input: lib.all (cfg: input != cfg.components.library or null) selected);
packageInputs = removeSelected
(lib.concatMap (cfg: cfg.depends) selectedConfigs
@ -37,7 +43,7 @@ let
# Add the system libraries and build tools of the selected haskell
# packages to the shell.
systemInputs = lib.concatMap (p: p.components.all.buildInputs) selected;
systemInputs = removeSelectedInputs (lib.concatMap (p: p.components.all.buildInputs) selected);
nativeBuildInputs = removeSelected
(lib.concatMap (p: p.components.all.executableToolDepends) selected);

View File

@ -13,7 +13,7 @@ in pkgs.lib.evalModules {
# as well as pkgconfPkgs, which are used to resolve pkgconfig name to nixpkgs names. We simply
# augment the existing pkgs set with the specific mappings:
pkgs = pkgs // (import ./lib/system-nixpkgs-map.nix pkgs);
pkgconfPkgs = pkgs // (import ./lib/pkgconf-nixpkgs-map.nix pkgs);
pkgconfPkgs = import ./lib/pkgconf-nixpkgs-map.nix pkgs;
inherit buildModules;
};