nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1# cd nixpkgs
2# nix-build -A tests.pkg-config.defaultPkgConfigPackages
3{
4 lib,
5 pkg-config,
6 defaultPkgConfigPackages,
7 runCommand,
8 testers,
9}:
10let
11 inherit (lib.strings) escapeNixIdentifier;
12
13 allTests = lib.mapAttrs (k: v: if v == null then null else makePkgConfigTestMaybe k v) (
14 builtins.removeAttrs defaultPkgConfigPackages [ "recurseForDerivations" ]
15 );
16
17 # nix-build rejects attribute names with periods
18 # This will build those regardless.
19 tests-combined =
20 runCommand "pkg-config-checks"
21 {
22 allTests = lib.attrValues allTests;
23 }
24 ''
25 touch $out
26 '';
27
28 makePkgConfigTestMaybe =
29 moduleName: pkg:
30 if !lib.isDerivation pkg then
31 throw "pkg-config module `${escapeNixIdentifier moduleName}` is not defined to be a derivation. Please check the attribute value for `${escapeNixIdentifier moduleName}` in `pkgs/top-level/pkg-config-packages.nix` in Nixpkgs."
32
33 else if !pkg ? meta.unsupported then
34 throw "pkg-config module `${escapeNixIdentifier moduleName}` does not have a `meta.unsupported` attribute. This can't be right. Please check the attribute value for `${escapeNixIdentifier moduleName}` in `pkgs/top-level/pkg-config-packages.nix` in Nixpkgs."
35
36 else if pkg.meta.unsupported then
37 # We return `null` instead of doing a `filterAttrs`, because with
38 # `filterAttrs` the evaluator would not be able to return the attribute
39 # set without first evaluating all of the attribute _values_. This would
40 # be rather expensive, and severely slow down the use case of getting a
41 # single test, which we want to do in `passthru.tests`, or interactively.
42 null
43
44 else if !pkg ? meta.broken then
45 throw "pkg-config module `${escapeNixIdentifier moduleName}` does not have a `meta.broken` attribute. This can't be right. Please check the attribute value for `${escapeNixIdentifier moduleName}` in `pkgs/top-level/pkg-config.packages.nix` in Nixpkgs."
46
47 else if pkg.meta.broken then
48 null
49
50 else
51 testers.hasPkgConfigModules {
52 moduleNames = [ moduleName ];
53 package = pkg;
54 };
55
56in
57lib.recurseIntoAttrs allTests // { inherit tests-combined; }