nixpkgs/pkgs/by-name/nl/nlohmann_json/package.nix
aleksana 571c71e6f7 treewide: migrate packages to pkgs/by-name, take 1
We are migrating packages that meet below requirements:

1. using `callPackage`
2. called path is a directory
3. overriding set is empty (`{ }`)
4. not containing path expressions other than relative path (to
makenixpkgs-vet happy)
5. not referenced by nix files outside of the directory, other
than`pkgs/top-level/all-packages.nix`
6. not referencing nix files outside of the directory
7. not referencing `default.nix` (since it's changed to `package.nix`)
8. `outPath` doesn't change after migration

The tool is here: https://github.com/Aleksanaa/by-name-migrate.
2024-11-09 20:04:51 +08:00

49 lines
1.3 KiB
Nix

{ stdenv
, lib
, fetchFromGitHub
, cmake
}:
let
testData = fetchFromGitHub {
owner = "nlohmann";
repo = "json_test_data";
rev = "v3.1.0";
hash = "sha256-bG34W63ew7haLnC82A3lS7bviPDnApLipaBjJAjLcVk=";
};
in stdenv.mkDerivation (finalAttrs: {
pname = "nlohmann_json";
version = "3.11.3";
src = fetchFromGitHub {
owner = "nlohmann";
repo = "json";
rev = "v${finalAttrs.version}";
hash = "sha256-7F0Jon+1oWL7uqet5i1IgHX0fUw/+z0QwEcA3zs5xHg=";
};
nativeBuildInputs = [ cmake ];
cmakeFlags = [
"-DJSON_BuildTests=${if finalAttrs.finalPackage.doCheck then "ON" else "OFF"}"
"-DJSON_FastTests=ON"
"-DJSON_MultipleHeaders=ON"
] ++ lib.optional finalAttrs.finalPackage.doCheck "-DJSON_TestDataDirectory=${testData}";
doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform;
# 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;
};
})