1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 pkgsBuildBuild,
6 cmake,
7 glib,
8 icu,
9 libxml2,
10 ninja,
11 perl,
12 pkg-config,
13 libical,
14 python3,
15 tzdata,
16 fixDarwinDylibNames,
17 withIntrospection ?
18 lib.meta.availableOn stdenv.hostPlatform gobject-introspection
19 && stdenv.hostPlatform.emulatorAvailable buildPackages,
20 buildPackages,
21 gobject-introspection,
22 vala,
23}:
24
25stdenv.mkDerivation (finalAttrs: {
26 pname = "libical";
27 version = "3.0.20";
28
29 outputs = [
30 "out"
31 "dev"
32 ]; # "devdoc" ];
33
34 src = fetchFromGitHub {
35 owner = "libical";
36 repo = "libical";
37 rev = "v${finalAttrs.version}";
38 sha256 = "sha256-KIMqZ6QAh+fTcKEYrcLlxgip91CLAwL9rwjUdKzBsQk=";
39 };
40
41 strictDeps = true;
42
43 depsBuildBuild = lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
44 # provides ical-glib-src-generator that runs during build
45 libical
46 ];
47
48 nativeBuildInputs = [
49 cmake
50 icu
51 ninja
52 perl
53 pkg-config
54 ]
55 ++ lib.optionals withIntrospection [
56 gobject-introspection
57 vala
58 # Docs building fails:
59 # https://github.com/NixOS/nixpkgs/pull/67204
60 # previously with https://github.com/NixOS/nixpkgs/pull/61657#issuecomment-495579489
61 # gtk-doc docbook_xsl docbook_xml_dtd_43 # for docs
62 ]
63 ++ lib.optionals stdenv.hostPlatform.isDarwin [
64 fixDarwinDylibNames
65 ];
66 nativeInstallCheckInputs = [
67 # running libical-glib tests
68 (python3.pythonOnBuildForHost.withPackages (
69 pkgs: with pkgs; [
70 pygobject3
71 ]
72 ))
73 ];
74
75 buildInputs = [
76 glib
77 libxml2
78 icu
79 ];
80
81 cmakeFlags = [
82 "-DENABLE_GTK_DOC=False"
83 "-DLIBICAL_BUILD_EXAMPLES=False"
84 "-DGOBJECT_INTROSPECTION=${if withIntrospection then "True" else "False"}"
85 "-DICAL_GLIB_VAPI=${if withIntrospection then "True" else "False"}"
86 "-DSTATIC_ONLY=${if stdenv.hostPlatform.isStatic then "True" else "False"}"
87 ]
88 ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
89 "-DIMPORT_ICAL_GLIB_SRC_GENERATOR=${lib.getDev pkgsBuildBuild.libical}/lib/cmake/LibIcal/IcalGlibSrcGenerator.cmake"
90 ];
91
92 patches = [
93 # Will appear in 3.1.0
94 # https://github.com/libical/libical/issues/350
95 ./respect-env-tzdir.patch
96
97 ./static.patch
98 ];
99
100 # Using install check so we do not have to manually set GI_TYPELIB_PATH
101 # Musl does not support TZDIR.
102 doInstallCheck = !stdenv.hostPlatform.isMusl;
103 enableParallelChecking = false;
104 preInstallCheck =
105 if stdenv.hostPlatform.isDarwin then
106 ''
107 for testexe in $(find ./src/test -maxdepth 1 -type f -executable); do
108 for lib in $(cd lib && ls *.3.dylib); do
109 install_name_tool -change $lib $out/lib/$lib $testexe
110 done
111 done
112 ''
113 else
114 null;
115 installCheckPhase = ''
116 runHook preInstallCheck
117
118 export TZDIR=${tzdata}/share/zoneinfo
119 ctest --output-on-failure
120
121 runHook postInstallCheck
122 '';
123
124 meta = {
125 homepage = "https://github.com/libical/libical";
126 description = "Open Source implementation of the iCalendar protocols";
127 changelog = "https://github.com/libical/libical/raw/v${finalAttrs.version}/ReleaseNotes.txt";
128 license = lib.licenses.mpl20;
129 platforms = lib.platforms.unix;
130 };
131})