1{ lib
2, stdenv
3, fetchFromGitLab
4, fetchpatch2
5, meson
6, ninja
7, pkg-config
8, gobject-introspection
9, gtk-doc
10, docbook-xsl-nons
11, docbook_xml_dtd_43
12, help2man
13, glib
14, python3
15, mesonEmulatorHook
16, libgudev
17, bash-completion
18, libmbim
19, libqrtr-glib
20, buildPackages
21, withIntrospection ? stdenv.hostPlatform.emulatorAvailable buildPackages
22, withMan ? stdenv.buildPlatform.canExecute stdenv.hostPlatform
23}:
24
25stdenv.mkDerivation rec {
26 pname = "libqmi";
27 version = "1.32.2";
28
29 outputs = [ "out" "dev" ]
30 ++ lib.optional withIntrospection "devdoc";
31
32 src = fetchFromGitLab {
33 domain = "gitlab.freedesktop.org";
34 owner = "mobile-broadband";
35 repo = "libqmi";
36 rev = version;
37 hash = "sha256-XIbeWgkPiJL8hN8Rb6KFt5Q5sG3KsiEQr0EnhwmI6h8=";
38 };
39
40 patches = [
41 # Fix pkg-config file missing qrtr in Requires.
42 # https://gitlab.freedesktop.org/mobile-broadband/libqmi/-/issues/99
43 (fetchpatch2 {
44 url = "https://gitlab.freedesktop.org/mobile-broadband/libqmi/-/commit/7d08150910974c6bd2c29f887c2c6d4a3526e085.patch";
45 hash = "sha256-LFrlm2ZqLqewLGO2FxL5kFYbZ7HaxdxvVHsFHYSgZ4Y=";
46 })
47 ];
48
49 nativeBuildInputs = [
50 meson
51 ninja
52 pkg-config
53 python3
54 ] ++ lib.optionals withMan [
55 help2man
56 ] ++ lib.optionals withIntrospection [
57 gobject-introspection
58 gtk-doc
59 docbook-xsl-nons
60 docbook_xml_dtd_43
61 ] ++ lib.optionals (withIntrospection && !stdenv.buildPlatform.canExecute stdenv.hostPlatform) [
62 mesonEmulatorHook
63 ];
64
65 buildInputs = [
66 bash-completion
67 libmbim
68 ] ++ lib.optionals withIntrospection [
69 libgudev
70 ];
71
72 propagatedBuildInputs = [
73 glib
74 ] ++ lib.optionals withIntrospection [
75 libqrtr-glib
76 ];
77
78 mesonFlags = [
79 "-Dudevdir=${placeholder "out"}/lib/udev"
80 (lib.mesonBool "gtk_doc" withIntrospection)
81 (lib.mesonBool "introspection" withIntrospection)
82 (lib.mesonBool "man" withMan)
83 (lib.mesonBool "qrtr" withIntrospection)
84 (lib.mesonBool "udev" withIntrospection)
85 ];
86
87 doCheck = true;
88
89 postPatch = ''
90 patchShebangs \
91 build-aux/qmi-codegen/qmi-codegen
92 '';
93
94 meta = with lib; {
95 homepage = "https://www.freedesktop.org/wiki/Software/libqmi/";
96 description = "Modem protocol helper library";
97 maintainers = teams.freedesktop.members;
98 platforms = platforms.linux;
99 license = with licenses; [
100 # Library
101 lgpl2Plus
102 # Tools
103 gpl2Plus
104 ];
105 changelog = "https://gitlab.freedesktop.org/mobile-broadband/libqmi/-/blob/${version}/NEWS";
106 };
107}