Files
nixpkgs/pkgs/by-name/cp/cpuinfo/package.nix

57 lines
1.8 KiB
Nix

{
lib,
fetchFromGitHub,
cmake,
pkg-config,
stdenv,
gtest,
nix-update-script,
testers,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "cpuinfo";
version = "0-unstable-2026-05-18";
src = fetchFromGitHub {
owner = "pytorch";
repo = "cpuinfo";
rev = "ea6b9f1bb6e1001d8b21574d5bc78ddef62e499d";
hash = "sha256-/QsOjDik0TnH3FnK7LOwsJkvX+O+2DRFX4eF3MxD3fc=";
};
passthru.updateScript = nix-update-script { extraArgs = [ "--version=branch" ]; };
passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
nativeBuildInputs = [
cmake
pkg-config
];
checkInputs = [ gtest ];
cmakeFlags = [
(lib.cmakeBool "CPUINFO_BUILD_UNIT_TESTS" finalAttrs.finalPackage.doCheck)
(lib.cmakeBool "CPUINFO_BUILD_MOCK_TESTS" finalAttrs.finalPackage.doCheck)
(lib.cmakeBool "CPUINFO_BUILD_BENCHMARKS" false)
(lib.cmakeBool "USE_SYSTEM_LIBS" true)
];
# The tests check what CPU the host has and makes sure it can query information.
# not all build environments may have this information available. And, cpuinfo may
# not understand all CPUs (causing test failures such as https://github.com/pytorch/cpuinfo/issues/132)
# Instead, allow building in any environment.
doCheck = false;
meta = {
description = "Tools and library to detect essential for performance optimization information about host CPU";
homepage = "https://github.com/pytorch/cpuinfo";
license = lib.licenses.bsd2;
mainProgram = "cpu-info";
maintainers = with lib.maintainers; [ pawelchcki ];
pkgConfigModules = [ "libcpuinfo" ];
# https://github.com/pytorch/cpuinfo/blob/ea6b9f1bb6e1001d8b21574d5bc78ddef62e499d/CMakeLists.txt#L98
platforms = lib.platforms.x86 ++ lib.platforms.aarch ++ lib.platforms.riscv;
};
})