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, glib-networking
18, buildPackages
19, withIntrospection ? stdenv.hostPlatform.emulatorAvailable buildPackages
20}:
21
22stdenv.mkDerivation rec {
23 pname = "libsoup";
24 version = "2.74.3";
25
26 outputs = [ "out" "dev" ];
27
28 src = fetchurl {
29 url = "mirror://gnome/sources/${pname}/${lib.versions.majorMinor version}/${pname}-${version}.tar.xz";
30 sha256 = "sha256-5Ld8Qc/EyMWgNfzcMgx7xs+3XvfFoDQVPfFBP6HZLxM=";
31 };
32
33 depsBuildBuild = [
34 pkg-config
35 ];
36
37 nativeBuildInputs = [
38 meson
39 ninja
40 pkg-config
41 glib
42 ] ++ lib.optionals withIntrospection [
43 gobject-introspection
44 vala
45 ];
46
47 buildInputs = [
48 sqlite
49 libpsl
50 glib.out
51 brotli
52 ] ++ lib.optionals stdenv.isLinux [
53 libsysprof-capture
54 ];
55
56 propagatedBuildInputs = [
57 glib
58 libxml2
59 ];
60
61 mesonFlags = [
62 "-Dtls_check=false" # glib-networking is a runtime dependency, not a compile-time dependency
63 "-Dgssapi=disabled"
64 "-Dvapi=${if withIntrospection then "enabled" else "disabled"}"
65 "-Dintrospection=${if withIntrospection then "enabled" else "disabled"}"
66 "-Dgnome=${lib.boolToString gnomeSupport}"
67 "-Dntlm=disabled"
68 ] ++ lib.optionals (!stdenv.isLinux) [
69 "-Dsysprof=disabled"
70 ];
71
72 env.NIX_CFLAGS_COMPILE = "-lpthread";
73
74 doCheck = false; # ERROR:../tests/socket-test.c:37:do_unconnected_socket_test: assertion failed (res == SOUP_STATUS_OK): (2 == 200)
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 propagatedUserEnvPackages = [
88 glib-networking.out
89 ];
90 updateScript = gnome.updateScript {
91 packageName = pname;
92 versionPolicy = "odd-unstable";
93 freeze = true;
94 };
95 };
96
97 meta = {
98 description = "HTTP client/server library for GNOME";
99 homepage = "https://wiki.gnome.org/Projects/libsoup";
100 license = lib.licenses.lgpl2Plus;
101 inherit (glib.meta) maintainers platforms;
102 };
103}