1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 fetchpatch,
6 cmake,
7 pkg-config,
8 zlib,
9 pcre2,
10 utf8proc,
11 expat,
12 sqlite,
13 openssl,
14 unixODBC,
15 libmysqlclient,
16 writableTmpDirAsHomeHook,
17}:
18
19stdenv.mkDerivation rec {
20 pname = "poco";
21
22 version = "1.14.1";
23
24 src = fetchFromGitHub {
25 owner = "pocoproject";
26 repo = "poco";
27 hash = "sha256-acq2eja61sH/QHwMPmiDNns2jvXRTk0se/tHj9XRSiU=";
28 rev = "poco-${version}-release";
29 };
30
31 nativeBuildInputs = [
32 cmake
33 pkg-config
34 ];
35
36 buildInputs = [
37 unixODBC
38 libmysqlclient
39 ];
40
41 propagatedBuildInputs = [
42 zlib
43 pcre2
44 utf8proc
45 expat
46 sqlite
47 openssl
48 ];
49
50 outputs = [
51 "out"
52 "dev"
53 ];
54
55 MYSQL_DIR = libmysqlclient;
56 MYSQL_INCLUDE_DIR = "${MYSQL_DIR}/include/mysql";
57
58 cmakeFlags =
59 let
60 excludeTestsRegex = lib.concatStringsSep "|" [
61 # These tests require running services, which the checkPhase is ill equipeed to provide
62 # TODO get them running in a nixosTest
63 "Redis"
64 "DataODBC"
65 "MongoDB"
66 "DataMySQL"
67 # network not accessible from nix sandbox
68 "NetSSL" # around 25 test failures
69 "Net" # could be made to work when public network access is patched out
70 ];
71 in
72 [
73 # use nix provided versions of sqlite, zlib, pcre, expat, ... instead of bundled versions
74 (lib.cmakeBool "POCO_UNBUNDLED" true)
75 (lib.cmakeBool "ENABLE_TESTS" true)
76 (lib.cmakeFeature "CMAKE_CTEST_ARGUMENTS" "--exclude-regex;'${excludeTestsRegex}'")
77 ];
78
79 patches = [
80 # Remove on next release
81 (fetchpatch {
82 name = "disable-included-pcre-if-pcre-is-linked-staticly";
83 # this happens when building pkgsStatic.poco
84 url = "https://patch-diff.githubusercontent.com/raw/pocoproject/poco/pull/4879.patch";
85 hash = "sha256-VFWuRuf0GPYFp43WKI8utl+agP+7a5biLg7m64EMnVo=";
86 })
87 # https://github.com/pocoproject/poco/issues/4977
88 ./disable-flaky-tests.patch
89 ]
90 ++ lib.optionals stdenv.hostPlatform.isDarwin [
91 ./disable-broken-tests-darwin.patch
92 ]
93 ++ lib.optionals stdenv.hostPlatform.isLinux [
94 ./disable-broken-tests-linux.patch
95 ];
96
97 doCheck = true;
98 nativeCheckInputs = [
99 # workaround for some tests trying to write to /homeless-shelter
100 writableTmpDirAsHomeHook
101 ];
102
103 postFixup = ''
104 grep -rlF INTERFACE_INCLUDE_DIRECTORIES "$dev/lib/cmake/Poco" | while read -r f; do
105 substituteInPlace "$f" \
106 --replace-quiet "$"'{_IMPORT_PREFIX}/include' ""
107 done
108 '';
109
110 meta = with lib; {
111 homepage = "https://pocoproject.org/";
112 description = "Cross-platform C++ libraries with a network/internet focus";
113 license = licenses.boost;
114 maintainers = with maintainers; [
115 orivej
116 tomodachi94
117 ];
118 platforms = platforms.unix;
119 };
120}