mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-17 11:13:30 +00:00
5a02dc8ee8
The existing nlohmann_json expression prevents users from overriding fields (like `doCheck`) because it uses `rec` in the argument to `mkDerivation`. Let's use the shiny new pass-a-function-to-`mkDerivation` feature to do the same thing without blocking overrides.
48 lines
1.2 KiB
Nix
48 lines
1.2 KiB
Nix
{ stdenv
|
|
, lib
|
|
, fetchFromGitHub
|
|
, cmake
|
|
}:
|
|
let
|
|
testData = fetchFromGitHub {
|
|
owner = "nlohmann";
|
|
repo = "json_test_data";
|
|
rev = "v3.0.0";
|
|
sha256 = "O6p2PFB7c2KE9VqWvmTaFywbW1hSzAP5V42EuemX+ls=";
|
|
};
|
|
in stdenv.mkDerivation (finalAttrs: {
|
|
pname = "nlohmann_json";
|
|
version = "3.10.5";
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "nlohmann";
|
|
repo = "json";
|
|
rev = "v${finalAttrs.version}";
|
|
sha256 = "DTsZrdB9GcaNkx7ZKxcgCA3A9ShM5icSF0xyGguJNbk=";
|
|
};
|
|
|
|
nativeBuildInputs = [ cmake ];
|
|
|
|
cmakeFlags = [
|
|
"-DBuildTests=${if finalAttrs.doCheck then "ON" else "OFF"}"
|
|
"-DJSON_MultipleHeaders=ON"
|
|
] ++ lib.optional finalAttrs.doCheck "-DJSON_TestDataDirectory=${testData}";
|
|
|
|
doCheck = stdenv.hostPlatform == stdenv.buildPlatform;
|
|
|
|
# skip tests that require git or modify “installed files”
|
|
preCheck = ''
|
|
checkFlagsArray+=("ARGS=-LE 'not_reproducible|git_required'")
|
|
'';
|
|
|
|
postInstall = "rm -rf $out/lib64";
|
|
|
|
meta = with lib; {
|
|
description = "JSON for Modern C++";
|
|
homepage = "https://json.nlohmann.me";
|
|
changelog = "https://github.com/nlohmann/json/blob/develop/ChangeLog.md";
|
|
license = licenses.mit;
|
|
platforms = platforms.all;
|
|
};
|
|
})
|