2023-01-29 08:54:13 +01:00
|
|
|
# cd nixpkgs
|
|
|
|
# nix-build -A tests.pkg-config.defaultPkgConfigPackages
|
2023-01-29 09:27:29 +01:00
|
|
|
{ lib, pkg-config, defaultPkgConfigPackages, runCommand, testers }:
|
2022-04-23 23:37:49 +02:00
|
|
|
let
|
2023-01-23 19:08:46 +01:00
|
|
|
inherit (lib.strings) escapeNixIdentifier;
|
|
|
|
|
2023-03-18 04:42:55 +01:00
|
|
|
allTests = lib.mapAttrs (k: v: if v == null then null else makePkgConfigTestMaybe k v)
|
|
|
|
(builtins.removeAttrs defaultPkgConfigPackages ["recurseForDerivations"]);
|
2022-04-23 23:37:49 +02:00
|
|
|
|
|
|
|
# nix-build rejects attribute names with periods
|
|
|
|
# This will build those regardless.
|
|
|
|
tests-combined = runCommand "pkg-config-checks" {
|
|
|
|
allTests = lib.attrValues allTests;
|
|
|
|
} ''
|
|
|
|
touch $out
|
|
|
|
'';
|
|
|
|
|
2023-01-23 19:08:46 +01:00
|
|
|
makePkgConfigTestMaybe = moduleName: pkg:
|
|
|
|
if ! lib.isDerivation pkg
|
|
|
|
then
|
|
|
|
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."
|
|
|
|
|
|
|
|
else if ! pkg?meta.unsupported
|
|
|
|
then
|
|
|
|
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."
|
|
|
|
|
|
|
|
else if pkg.meta.unsupported
|
|
|
|
then
|
|
|
|
# We return `null` instead of doing a `filterAttrs`, because with
|
|
|
|
# `filterAttrs` the evaluator would not be able to return the attribute
|
|
|
|
# set without first evaluating all of the attribute _values_. This would
|
|
|
|
# be rather expensive, and severly slow down the use case of getting a
|
|
|
|
# single test, which we want to do in `passthru.tests`, or interactively.
|
|
|
|
null
|
|
|
|
|
2023-01-23 19:11:20 +01:00
|
|
|
else if ! pkg?meta.broken
|
|
|
|
then
|
|
|
|
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."
|
|
|
|
|
|
|
|
else if pkg.meta.broken
|
|
|
|
then null
|
|
|
|
|
2023-08-08 12:51:22 +02:00
|
|
|
else testers.hasPkgConfigModules { moduleNames = [ moduleName ]; package = pkg; };
|
2023-01-23 19:08:46 +01:00
|
|
|
|
2022-04-23 23:37:49 +02:00
|
|
|
in
|
2023-01-31 04:16:51 +01:00
|
|
|
lib.recurseIntoAttrs allTests // { inherit tests-combined; }
|