2 { lib, runCommand, pkg-config }:
6 moduleNames ? package.meta.pkgConfigModules,
7 testName ? "check-pkg-config-${lib.concatStringsSep "-" moduleNames}",
8 version ? package.version or null,
13 nativeBuildInputs = [ pkg-config ];
14 buildInputs = [ package ];
15 inherit moduleNames version versionCheck;
17 description = "Test whether ${package.name} exposes pkg-config modules ${lib.concatStringsSep ", " moduleNames}.";
19 # Make sure licensing info etc is preserved, as this is a concern for e.g. cache.nixos.org,
20 # as hydra can't check this meta info in dependencies.
21 # The test itself is just Nixpkgs, with MIT license.
22 // builtins.intersectAttrs
24 available = throw "unused";
25 broken = throw "unused";
26 insecure = throw "unused";
27 license = throw "unused";
28 maintainers = throw "unused";
29 platforms = throw "unused";
30 unfree = throw "unused";
31 unsupported = throw "unused";
38 for moduleName in $moduleNames; do
39 echo "checking pkg-config module $moduleName in $buildInputs"
41 moduleVersion="$($PKG_CONFIG --modversion $moduleName)"
45 if [[ "$moduleVersion" == "$version" ]]; then
46 echo "✅ pkg-config module $moduleName exists and has version $moduleVersion"
48 echo "❌ pkg-config module $moduleName exists and has version $moduleVersion when $version was expected"
49 ((versionMismatch+=1))
51 printf '%s\t%s\n' "$moduleName" "$version" >> "$out"
53 echo "❌ pkg-config module $moduleName was not found"
58 if [[ $notFound -eq 0 ]] && ([[ $versionMismatch -eq 0 ]] || [[ "$versionCheck" == false ]]); then
61 if [[ $notFound -ne 0 ]]; then
62 echo "$notFound modules not found"
63 echo "These modules were available in the input propagation closure:"
64 $PKG_CONFIG --list-all
66 if [[ $versionMismatch -ne 0 ]]; then
67 echo "$versionMismatch version mismatches"