summary refs log tree commit diff
path: root/pkgs/development/libraries/cmark/default.nix
blob: d78db53ea4b5a71856bf61bff9395b6fcfe7829c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
{ lib, stdenv, fetchFromGitHub, fetchpatch, cmake }:

stdenv.mkDerivation rec {
  pname = "cmark";
  version = "0.30.1";

  src = fetchFromGitHub {
    owner = "jgm";
    repo = pname;
    rev = version;
    sha256 = "sha256-UjDM2N6gCwO94F1nW3qCP9JX42MYAicAuGTKAXMy1Gg=";
  };

  patches = [
    # Fix libcmark.pc paths (should be incorporated next release)
    (fetchpatch {
      url = "https://github.com/commonmark/cmark/commit/15762d7d391483859c241cdf82b1615c6b6a5a19.patch";
      sha256 = "sha256-wdyK1tQolgfiwYMAaWMQZdCSbMDCijug5ykpoDl/HwI=";
    })
  ];

  nativeBuildInputs = [ cmake ];

  cmakeFlags = [
    # https://github.com/commonmark/cmark/releases/tag/0.30.1
    # recommends distributions dynamically link
    "-DCMARK_STATIC=OFF"
  ];

  doCheck = true;

  preCheck = let
    lib_path = if stdenv.isDarwin then "DYLD_FALLBACK_LIBRARY_PATH" else "LD_LIBRARY_PATH";
  in ''
    export ${lib_path}=$(readlink -f ./src)
  '';

  meta = with lib; {
    description = "CommonMark parsing and rendering library and program in C";
    homepage = "https://github.com/jgm/cmark";
    maintainers = [ maintainers.michelk ];
    platforms = platforms.unix;
    license = licenses.bsd2;
  };
}