1{ stdenv
2, fetchpatch
3, fetchFromGitLab
4, cmake
5, ninja
6, pkg-config
7, boost
8, glib
9, gsl
10, cairo
11, double-conversion
12, gtest
13, lib
14}:
15
16stdenv.mkDerivation rec {
17 pname = "lib2geom";
18 version = "1.3";
19
20 outputs = [ "out" "dev" ];
21
22 src = fetchFromGitLab {
23 owner = "inkscape";
24 repo = "lib2geom";
25 rev = "refs/tags/${version}";
26 hash = "sha256-llUpW8VRBD8RKaGfyedzsMbLRb8DIo0ePt6m2T2w7Po=";
27 };
28
29 patches = [
30 # Fix compilation with Clang.
31 # https://gitlab.com/inkscape/lib2geom/-/merge_requests/102
32 (fetchpatch {
33 url = "https://gitlab.com/inkscape/lib2geom/-/commit/a5b5ac7d992023f8a80535ede60421e73ecd8e20.patch";
34 hash = "sha256-WJYkk3WRYVyPSvyTbKDUrYvUwFgKA9mmTiEWtYQqM4Q=";
35 })
36 (fetchpatch {
37 url = "https://gitlab.com/inkscape/lib2geom/-/commit/23d9393af4bee17aeb66a3c13bdad5dbed982d08.patch";
38 hash = "sha256-LAaGMIXpDI/Wzv5E2LasW1Y2/G4ukhuEzDmFu3AzZOA=";
39 })
40
41 # Fix ellipses rendering near page corners.
42 # https://gitlab.com/inkscape/lib2geom/-/issues/66
43 (fetchpatch {
44 url = "https://gitlab.com/inkscape/lib2geom/-/commit/039ce8d4af23a0a2a9d48eb970b321d9795dcc08.patch";
45 hash = "sha256-JfgGrqBcYSYKcdl4Bt7vGZ4aTBPSHM6JjZ95IlzxPwI=";
46 })
47 (fetchpatch {
48 url = "https://gitlab.com/inkscape/lib2geom/-/commit/cf523857e48c87f9f6a09217bdf935fff457823d.patch";
49 hash = "sha256-BRg8ANHMSgoi6vt9PNbhwG1fRkzEPXb4gPTPO3sY0XE=";
50 })
51 ];
52
53 nativeBuildInputs = [
54 cmake
55 ninja
56 pkg-config
57 ];
58
59 buildInputs = [
60 boost
61 glib
62 gsl
63 cairo
64 double-conversion
65 ];
66
67 nativeCheckInputs = [
68 gtest
69 ];
70
71 cmakeFlags = [
72 "-D2GEOM_BUILD_SHARED=ON"
73 ];
74
75 doCheck = true;
76
77 # TODO: Update cmake hook to make it simpler to selectively disable cmake tests: #113829
78 checkPhase = let
79 disabledTests =
80 lib.optionals stdenv.isAarch64 [
81 # Broken on all platforms, test just accidentally passes on some.
82 # https://gitlab.com/inkscape/lib2geom/-/issues/63
83 "elliptical-arc-test"
84 ]
85 ++ lib.optionals stdenv.hostPlatform.isMusl [
86 # Fails due to rounding differences
87 # https://gitlab.com/inkscape/lib2geom/-/issues/70
88 "circle-test"
89 ]
90 ;
91 in ''
92 runHook preCheck
93 ctest --output-on-failure -E '^${lib.concatStringsSep "|" disabledTests}$'
94 runHook postCheck
95 '';
96
97 meta = with lib; {
98 description = "Easy to use 2D geometry library in C++";
99 homepage = "https://gitlab.com/inkscape/lib2geom";
100 license = [ licenses.lgpl21Only licenses.mpl11 ];
101 maintainers = with maintainers; [ jtojnar ];
102 platforms = platforms.unix;
103 };
104}