1{ lib, stdenv, fetchFromGitHub, cmake }:
2
3stdenv.mkDerivation rec {
4 pname = "cmark";
5 version = "0.30.3";
6
7 src = fetchFromGitHub {
8 owner = "commonmark";
9 repo = pname;
10 rev = version;
11 sha256 = "sha256-/7TzaZYP8lndkfRPgCpBbazUBytVLXxqWHYktIsGox0=";
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 homepage = "https://github.com/commonmark/cmark";
33 changelog = "https://github.com/commonmark/cmark/raw/${version}/changelog.txt";
34 maintainers = [ maintainers.michelk ];
35 platforms = platforms.all;
36 license = licenses.bsd2;
37 };
38}