1{ stdenv
2, lib
3, fetchurl
4, glib
5, libxml2
6, meson
7, ninja
8, pkg-config
9, gnome
10, libsysprof-capture
11, gobject-introspection
12, vala
13, libpsl
14, brotli
15, gnomeSupport ? true
16, sqlite
17, buildPackages
18, withIntrospection ? lib.meta.availableOn stdenv.hostPlatform gobject-introspection && stdenv.hostPlatform.emulatorAvailable buildPackages
19}:
20
21stdenv.mkDerivation rec {
22 pname = "libsoup";
23 version = "2.74.3";
24
25 outputs = [ "out" "dev" ];
26
27 src = fetchurl {
28 url = "mirror://gnome/sources/${pname}/${lib.versions.majorMinor version}/${pname}-${version}.tar.xz";
29 sha256 = "sha256-5Ld8Qc/EyMWgNfzcMgx7xs+3XvfFoDQVPfFBP6HZLxM=";
30 };
31
32 depsBuildBuild = [
33 pkg-config
34 ];
35
36 nativeBuildInputs = [
37 meson
38 ninja
39 pkg-config
40 glib
41 ] ++ lib.optionals withIntrospection [
42 gobject-introspection
43 vala
44 ];
45
46 buildInputs = [
47 sqlite
48 libpsl
49 glib.out
50 brotli
51 ] ++ lib.optionals stdenv.isLinux [
52 libsysprof-capture
53 ];
54
55 propagatedBuildInputs = [
56 glib
57 libxml2
58 ];
59
60 mesonFlags = [
61 "-Dtls_check=false" # glib-networking is a runtime dependency, not a compile-time dependency
62 "-Dgssapi=disabled"
63 "-Dvapi=${if withIntrospection then "enabled" else "disabled"}"
64 "-Dintrospection=${if withIntrospection then "enabled" else "disabled"}"
65 "-Dgnome=${lib.boolToString gnomeSupport}"
66 "-Dntlm=disabled"
67 ] ++ lib.optionals (!stdenv.isLinux) [
68 "-Dsysprof=disabled"
69 ];
70
71 env.NIX_CFLAGS_COMPILE = "-lpthread";
72
73 doCheck = false; # ERROR:../tests/socket-test.c:37:do_unconnected_socket_test: assertion failed (res == SOUP_STATUS_OK): (2 == 200)
74 separateDebugInfo = true;
75
76 postPatch = ''
77 # fixes finding vapigen when cross-compiling
78 # the commit is in 3.0.6
79 # https://gitlab.gnome.org/GNOME/libsoup/-/commit/5280e936d0a76f94dbc5d8489cfbdc0a06343f65
80 substituteInPlace meson.build \
81 --replace "required: vapi_opt)" "required: vapi_opt, native: false)"
82
83 patchShebangs libsoup/
84 '';
85
86 passthru = {
87 updateScript = gnome.updateScript {
88 packageName = pname;
89 versionPolicy = "odd-unstable";
90 freeze = true;
91 };
92 };
93
94 meta = {
95 description = "HTTP client/server library for GNOME";
96 homepage = "https://gitlab.gnome.org/GNOME/libsoup";
97 license = lib.licenses.lgpl2Plus;
98 inherit (glib.meta) maintainers platforms;
99 pkgConfigModules = [
100 "libsoup-2.4"
101 "libsoup-gnome-2.4"
102 ];
103 };
104}