Skip to content

Commit ea40f5c

Browse files
committed
devshell: better definition of PKG_CONFIG_PATH
that manually going through pkg-config of all packages. Also filter out non-derivation from nativeBuildInputs.
1 parent a1d318e commit ea40f5c

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

lib/project-overlays.nix

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,17 @@
77
devshell = final: prev: {
88
devshell = let
99
in {
10-
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)))
10+
packages = lib.filter lib.isDerivation (final.shell.nativeBuildInputs
1511
# devshell does not use pkgs.mkShell / pkgs.stdenv.mkDerivation,
1612
# so we need to explicit required dependencies which
1713
# are provided implicitely by stdenv when using the normal shell:
18-
++ (lib.filter lib.isDerivation final.shell.stdenv.defaultNativeBuildInputs)
14+
++ final.shell.stdenv.defaultNativeBuildInputs)
1915
++ lib.optional final.shell.stdenv.targetPlatform.isGnu final.pkgs.buildPackages.binutils;
2016
# We need to expose all the necessary env variables:
2117
env = [
2218
{
2319
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";
20+
value = lib.makeSearchPath "lib/pkgconfig" final.shell.buildInputs;
2621
}
2722
] ++ lib.mapAttrsToList lib.nameValuePair ({
2823
inherit (final.shell) NIX_GHC_LIBDIR;

0 commit comments

Comments
 (0)