1{ stdenv, lib, jekyll, cmake, fetchFromGitHub, gtest }:
2
3stdenv.mkDerivation rec {
4 pname = "jsonnet";
5 version = "0.20.0";
6 outputs = [ "out" "doc" ];
7
8 src = fetchFromGitHub {
9 rev = "v${version}";
10 owner = "google";
11 repo = "jsonnet";
12 sha256 = "sha256-FtVJE9alEl56Uik+nCpJMV5DMVVmRCnE1xMAiWdK39Y=";
13 };
14
15 nativeBuildInputs = [ jekyll cmake ];
16 buildInputs = [ gtest ];
17
18 cmakeFlags = [
19 "-DUSE_SYSTEM_GTEST=ON"
20 "-DBUILD_STATIC_LIBS=${if stdenv.hostPlatform.isStatic then "ON" else "OFF"}"
21 ] ++ lib.optionals (!stdenv.isDarwin) [
22 "-DBUILD_SHARED_BINARIES=${if stdenv.hostPlatform.isStatic then "OFF" else "ON"}"
23 ];
24
25 # https://github.com/google/jsonnet/issues/778
26 patches = [
27 ./fix-cpp-unresolved-symbols.patch
28 ];
29
30 enableParallelBuilding = true;
31
32 # Upstream writes documentation in html, not in markdown/rst, so no
33 # other output formats, sorry.
34 postBuild = ''
35 jekyll build --source ../doc --destination ./html
36 '';
37
38 postInstall = ''
39 mkdir -p $out/share/doc/jsonnet
40 cp -r ./html $out/share/doc/jsonnet
41 '';
42
43 meta = {
44 description = "Purely-functional configuration language that helps you define JSON data";
45 maintainers = with lib.maintainers; [ benley copumpkin ];
46 license = lib.licenses.asl20;
47 homepage = "https://github.com/google/jsonnet";
48 platforms = lib.platforms.unix;
49 };
50}