Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{
2 lib,
3 stdenv,
4 fetchFromGitLab,
5 fetchpatch,
6 glib,
7 libgudev,
8 ppp,
9 gettext,
10 pkg-config,
11 libxslt,
12 python3,
13 libmbim,
14 libqmi,
15 bash-completion,
16 meson,
17 ninja,
18 vala,
19 dbus,
20 bash,
21 gobject-introspection,
22 udevCheckHook,
23 buildPackages,
24 withIntrospection ?
25 lib.meta.availableOn stdenv.hostPlatform gobject-introspection
26 && stdenv.hostPlatform.emulatorAvailable buildPackages,
27 polkit,
28 withPolkit ? lib.meta.availableOn stdenv.hostPlatform polkit,
29 systemd,
30 withSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd,
31}:
32
33stdenv.mkDerivation rec {
34 pname = "modemmanager";
35 version = "1.22.0";
36
37 src = fetchFromGitLab {
38 domain = "gitlab.freedesktop.org";
39 owner = "mobile-broadband";
40 repo = "ModemManager";
41 rev = version;
42 hash = "sha256-/D9b2rCCUhpDCUfSNAWR65+3EyUywzFdH1R17eSKRDo=";
43 };
44
45 patches = [
46 # Since /etc is the domain of NixOS, not Nix, we cannot install files there.
47 # But these are just placeholders so we do not need to install them at all.
48 ./no-dummy-dirs-in-sysconfdir.patch
49
50 (fetchpatch {
51 name = "GI_TYPELIB_PATH.patch";
52 url = "https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/commit/daa829287894273879799a383ed4dc373c6111b0.patch";
53 hash = "sha256-tPQokiZO2SpTlX8xMlkWjP1AIXgoLHW3rJwnmG33z/k=";
54 })
55 ];
56
57 strictDeps = true;
58
59 nativeBuildInputs = [
60 meson
61 ninja
62 gettext
63 glib
64 pkg-config
65 libxslt
66 python3
67 udevCheckHook
68 ]
69 ++ lib.optionals withIntrospection [
70 gobject-introspection
71 vala
72 ];
73
74 buildInputs = [
75 glib
76 libgudev
77 ppp
78 libmbim
79 libqmi
80 bash-completion
81 dbus
82 bash # shebangs in share/ModemManager/fcc-unlock.available.d/
83 ]
84 ++ lib.optionals withPolkit [
85 polkit
86 ]
87 ++ lib.optionals withSystemd [
88 systemd
89 ];
90
91 nativeInstallCheckInputs = [
92 python3
93 python3.pkgs.dbus-python
94 python3.pkgs.pygobject3
95 ];
96
97 mesonFlags = [
98 "-Dudevdir=${placeholder "out"}/lib/udev"
99 "-Ddbus_policy_dir=${placeholder "out"}/share/dbus-1/system.d"
100 "-Dsystemdsystemunitdir=${placeholder "out"}/lib/systemd/system"
101 "--sysconfdir=/etc"
102 "--localstatedir=/var"
103 (lib.mesonBool "introspection" withIntrospection)
104 (lib.mesonBool "qrtr" withIntrospection)
105 (lib.mesonBool "vapi" withIntrospection)
106 (lib.mesonBool "systemd_suspend_resume" withSystemd)
107 (lib.mesonBool "systemd_journal" withSystemd)
108 (lib.mesonOption "polkit" (if withPolkit then "strict" else "no"))
109 ];
110
111 postPatch = ''
112 patchShebangs \
113 tools/test-modemmanager-service.py
114 '';
115
116 # In Nixpkgs g-ir-scanner is patched to produce absolute paths, and
117 # that interferes with ModemManager's tests, causing them to try to
118 # load libraries from the install path, which doesn't usually exist
119 # when `meson test' is run. So to work around that, we run it as an
120 # install check instead, when those paths will have been created.
121 doInstallCheck = withIntrospection;
122 installCheckPhase = ''
123 runHook preInstallCheck
124 export G_TEST_DBUS_DAEMON="${dbus}/bin/dbus-daemon"
125 patchShebangs tools/tests/test-wrapper.sh
126 mesonCheckPhase
127 runHook postInstallCheck
128 '';
129
130 meta = with lib; {
131 description = "WWAN modem manager, part of NetworkManager";
132 homepage = "https://www.freedesktop.org/wiki/Software/ModemManager/";
133 license = licenses.gpl2Plus;
134 teams = [ teams.freedesktop ];
135 platforms = platforms.linux;
136 };
137}