tests.pkg-configPackages: Filter out unsupported packages
This commit is contained in:
parent
7790eafbdc
commit
e93cfb250b
2 changed files with 39 additions and 2 deletions
|
@ -51,7 +51,22 @@ with pkgs;
|
|||
|
||||
php = recurseIntoAttrs (callPackages ./php {});
|
||||
|
||||
pkg-configPackages = callPackage ./pkg-config-packages.nix { };
|
||||
pkg-configPackages =
|
||||
let
|
||||
# pkg-configPackages test needs a Nixpkgs with allowUnsupportedPlatform
|
||||
# in order to filter out the unsupported packages without throwing any errors
|
||||
# tryEval would be too fragile, masking different problems as if they're
|
||||
# unsupported platform problems.
|
||||
allPkgs = import ../top-level {
|
||||
system = pkgs.stdenv.hostPlatform.system;
|
||||
localSystem = pkgs.stdenv.hostPlatform.system;
|
||||
config = {
|
||||
allowUnsupportedSystem = true;
|
||||
};
|
||||
overlays = [];
|
||||
};
|
||||
in
|
||||
allPkgs.callPackage ./pkg-config-packages.nix { };
|
||||
|
||||
rustCustomSysroot = callPackage ./rust-sysroot {};
|
||||
buildRustCrate = callPackage ../build-support/rust/build-rust-crate/test { };
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
{ lib, pkg-config, pkg-configPackages, runCommand }:
|
||||
let
|
||||
allTests = lib.mapAttrs (k: v: if v == null then null else makePkgConfigTest k v) pkg-configPackages;
|
||||
inherit (lib.strings) escapeNixIdentifier;
|
||||
|
||||
allTests = lib.mapAttrs (k: v: if v == null then null else makePkgConfigTestMaybe k v) pkg-configPackages;
|
||||
|
||||
# nix-build rejects attribute names with periods
|
||||
# This will build those regardless.
|
||||
|
@ -10,6 +12,26 @@ let
|
|||
touch $out
|
||||
'';
|
||||
|
||||
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
|
||||
|
||||
else makePkgConfigTest moduleName pkg;
|
||||
|
||||
makePkgConfigTest = moduleName: pkg: runCommand "check-pkg-config-${moduleName}" {
|
||||
nativeBuildInputs = [ pkg-config ];
|
||||
buildInputs = [ pkg ];
|
||||
|
|
Loading…
Reference in a new issue