1{ lib, stdenv, fetchFromGitHub, cmake }:
2
3stdenv.mkDerivation rec {
4 pname = "cmark";
5 version = "0.31.0";
6
7 src = fetchFromGitHub {
8 owner = "commonmark";
9 repo = pname;
10 rev = version;
11 sha256 = "sha256-GBesKTp9DqoFAmCc0RB+XePvzV9g+w+oyrD1nCgyklI=";
12 };
13
14 nativeBuildInputs = [ cmake ];
15
16 cmakeFlags =
17 # Link the executable with the shared library on system with shared libraries.
18 lib.optional (!stdenv.hostPlatform.isStatic) "-DCMARK_STATIC=OFF"
19 # Do not attempt to build .so library on static platform.
20 ++ lib.optional stdenv.hostPlatform.isStatic "-DCMARK_SHARED=OFF";
21
22 doCheck = true;
23
24 preCheck = let
25 lib_path = if stdenv.isDarwin then "DYLD_FALLBACK_LIBRARY_PATH" else "LD_LIBRARY_PATH";
26 in ''
27 export ${lib_path}=$(readlink -f ./src)
28 '';
29
30 meta = with lib; {
31 description = "CommonMark parsing and rendering library and program in C";
32 mainProgram = "cmark";
33 homepage = "https://github.com/commonmark/cmark";
34 changelog = "https://github.com/commonmark/cmark/raw/${version}/changelog.txt";
35 maintainers = [ maintainers.michelk ];
36 platforms = platforms.all;
37 license = licenses.bsd2;
38 };
39}