Skip to content

Commit 4852bdb

Browse files
authored
devshell: add pkg-config dependencies and set PKG_CONFIG_PATH. (#1725)
1 parent ec0c59e commit 4852bdb

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

lib/project-overlays.nix

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,23 @@
88
devshell = let
99
in {
1010
packages = final.shell.nativeBuildInputs
11+
# Cannot add the whole final.shell.buildInputs list because many collide with each other when fused.
12+
# So we only add what is really used (by pkg-config):
13+
++ map (p: p.dev or p) (lib.concatLists (lib.concatMap (p: p.components.library.pkgconfig or [] ++ p.components.setup.pkgconfig or [] ++ lib.concatMap (c: lib.concatMap (a: a.pkgconfig) (lib.attrValues c)) (lib.attrValues (removeAttrs p.components ["library" "setup"])))
14+
(lib.attrValues final.pkg-set.config.packages)))
1115
# devshell does not use pkgs.mkShell / pkgs.stdenv.mkDerivation,
1216
# so we need to explicit required dependencies which
1317
# are provided implicitely by stdenv when using the normal shell:
1418
++ (lib.filter lib.isDerivation final.shell.stdenv.defaultNativeBuildInputs)
1519
++ lib.optional final.shell.stdenv.targetPlatform.isGnu final.pkgs.buildPackages.binutils;
16-
env = lib.mapAttrsToList lib.nameValuePair ({
20+
# We need to expose all the necessary env variables:
21+
env = [
22+
{
23+
name = "PKG_CONFIG_PATH";
24+
# devshell fuse every all `packages` into a single directory ($DEVSHELL_DIR), so we use it:
25+
prefix = "$DEVSHELL_DIR/lib/pkgconfig";
26+
}
27+
] ++ lib.mapAttrsToList lib.nameValuePair ({
1728
inherit (final.shell) NIX_GHC_LIBDIR;
1829
# CABAL_CONFIG is only set if the shell was built with exactDeps=true
1930
} // lib.optionalAttrs (final.shell ? CABAL_CONFIG) {

0 commit comments

Comments
 (0)