mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-10-21 11:43:11 -04:00
e0464e4788
In preparation for the deprecation of `stdenv.isX`. These shorthands are not conducive to cross-compilation because they hide the platforms. Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way One example of why this is bad and especially affects compiler packages https://www.github.com/NixOS/nixpkgs/pull/343059 There are too many files to go through manually but a treewide should get users thinking when they see a `hostPlatform.isX` in a place where it doesn't make sense. ``` fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is" fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is" ```
60 lines
1.3 KiB
Nix
60 lines
1.3 KiB
Nix
{ stdenv
|
|
, lib
|
|
, fetchFromGitHub
|
|
, cmake
|
|
, gflags
|
|
, staticOnly ? stdenv.hostPlatform.isStatic
|
|
}:
|
|
|
|
stdenv.mkDerivation rec {
|
|
pname = "crc32c";
|
|
version = "1.1.2";
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "google";
|
|
repo = "crc32c";
|
|
rev = version;
|
|
sha256 = "0c383p7vkfq9rblww6mqxz8sygycyl27rr0j3bzb8l8ga71710ii";
|
|
fetchSubmodules = true;
|
|
};
|
|
|
|
nativeBuildInputs = [ cmake ];
|
|
buildInputs = [ gflags ];
|
|
|
|
env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.hostPlatform.isAarch64 "-march=armv8-a+crc";
|
|
|
|
cmakeFlags = [
|
|
"-DCRC32C_INSTALL=1"
|
|
"-DCRC32C_BUILD_TESTS=1"
|
|
"-DCRC32C_BUILD_BENCHMARKS=0"
|
|
"-DCRC32C_USE_GLOG=0"
|
|
"-DINSTALL_GTEST=0"
|
|
"-DBUILD_SHARED_LIBS=${if staticOnly then "0" else "1"}"
|
|
];
|
|
|
|
doCheck = false;
|
|
doInstallCheck = true;
|
|
|
|
installCheckPhase = ''
|
|
runHook preInstallCheck
|
|
|
|
ctest
|
|
|
|
runHook postInstallCheck
|
|
'';
|
|
|
|
postFixup = ''
|
|
# fix bogus include paths
|
|
for f in $(find $out/lib/cmake -name '*.cmake'); do
|
|
substituteInPlace "$f" --replace "\''${_IMPORT_PREFIX}/$out/include" "\''${_IMPORT_PREFIX}/include"
|
|
done
|
|
'';
|
|
|
|
meta = with lib; {
|
|
homepage = "https://github.com/google/crc32c";
|
|
description = "CRC32C implementation with support for CPU-specific acceleration instructions";
|
|
license = with licenses; [ bsd3 ];
|
|
maintainers = with maintainers; [ cpcloud ];
|
|
};
|
|
}
|