nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchurl,
5 replaceVars,
6 gettext,
7 pkg-config,
8 dbus,
9 gitUpdater,
10 libuuid,
11 polkit,
12 gnutls,
13 ppp,
14 dhcpcd,
15 iptables,
16 nftables,
17 python3,
18 vala,
19 libgcrypt,
20 dnsmasq,
21 bluez5,
22 readline,
23 libselinux,
24 audit,
25 gobject-introspection,
26 perl,
27 modemmanager,
28 openresolv,
29 libndp,
30 newt,
31 ethtool,
32 gnused,
33 iputils,
34 kmod,
35 jansson,
36 elfutils,
37 gtk-doc,
38 libxslt,
39 docbook_xsl,
40 docbook_xml_dtd_412,
41 docbook_xml_dtd_42,
42 docbook_xml_dtd_43,
43 curl,
44 meson,
45 mesonEmulatorHook,
46 ninja,
47 libnvme,
48 libpsl,
49 mobile-broadband-provider-info,
50 runtimeShell,
51 buildPackages,
52 nixosTests,
53 systemd,
54 udev,
55 udevCheckHook,
56 withSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd,
57 # NBFT (NVMe Boot Firmware Table) support, opt-in due to closure size
58 # https://github.com/NixOS/nixpkgs/pull/446121#discussion_r2380598419
59 withNbft ? false,
60}:
61
62let
63 pythonForDocs = python3.pythonOnBuildForHost.withPackages (pkgs: with pkgs; [ pygobject3 ]);
64in
65stdenv.mkDerivation (finalAttrs: {
66 pname = "networkmanager";
67 version = "1.54.3";
68
69 src = fetchurl {
70 url = "https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/releases/${finalAttrs.version}/downloads/NetworkManager-${finalAttrs.version}.tar.xz";
71 hash = "sha256-z0/vw76WgCxaTas+aQvcTOTHglGVTvChtlAm2IZwmYk=";
72 };
73
74 outputs = [
75 "out"
76 "dev"
77 "devdoc"
78 "man"
79 "doc"
80 ];
81
82 # Right now we hardcode quite a few paths at build time. Probably we should
83 # patch networkmanager to allow passing these path in config file. This will
84 # remove unneeded build-time dependencies.
85 mesonFlags = [
86 # System paths
87 "--sysconfdir=/etc"
88 "--localstatedir=/var"
89 (lib.mesonOption "systemdsystemunitdir" (
90 if withSystemd then "${placeholder "out"}/etc/systemd/system" else "no"
91 ))
92 # to enable link-local connections
93 "-Dudev_dir=${placeholder "out"}/lib/udev"
94 "-Ddbus_conf_dir=${placeholder "out"}/share/dbus-1/system.d"
95 "-Dkernel_firmware_dir=/run/current-system/firmware"
96
97 # Platform
98 "-Dmodprobe=${kmod}/bin/modprobe"
99 (lib.mesonOption "session_tracking" (if withSystemd then "systemd" else "no"))
100 (lib.mesonBool "systemd_journal" withSystemd)
101 "-Dlibaudit=yes-disabled-by-default"
102 "-Dpolkit_agent_helper_1=/run/wrappers/bin/polkit-agent-helper-1"
103
104 # Features
105 # Allow using iwd when configured to do so
106 "-Diwd=true"
107 "-Dpppd=${ppp}/bin/pppd"
108 "-Diptables=${iptables}/bin/iptables"
109 "-Dnft=${nftables}/bin/nft"
110 "-Dmodem_manager=true"
111 "-Dnmtui=true"
112 "-Ddnsmasq=${dnsmasq}/bin/dnsmasq"
113 "-Dqt=false"
114 (lib.mesonBool "nbft" withNbft)
115
116 # Handlers
117 "-Dresolvconf=${openresolv}/bin/resolvconf"
118
119 # DHCP clients
120 "-Ddhcpcd=${dhcpcd}/bin/dhcpcd"
121
122 # Miscellaneous
123 # almost cross-compiles, however fails with
124 # ** (process:9234): WARNING **: Failed to load shared library '/nix/store/...-networkmanager-aarch64-unknown-linux-gnu-1.38.2/lib/libnm.so.0' referenced by the typelib: /nix/store/...-networkmanager-aarch64-unknown-linux-gnu-1.38.2/lib/libnm.so.0: cannot open shared object file: No such file or directory
125 "-Ddocs=${lib.boolToString (stdenv.buildPlatform == stdenv.hostPlatform)}"
126 "-Dtests=no"
127 "-Dcrypto=gnutls"
128 "-Dmobile_broadband_provider_info_database=${mobile-broadband-provider-info}/share/mobile-broadband-provider-info/serviceproviders.xml"
129 ];
130
131 patches = [
132 (replaceVars ./fix-paths.patch {
133 inherit
134 iputils
135 ethtool
136 gnused
137 ;
138 inherit runtimeShell;
139 })
140
141 # Meson does not support using different directories during build and
142 # for installation like Autotools did with flags passed to make install.
143 ./fix-install-paths.patch
144 ];
145
146 buildInputs = [
147 (if withSystemd then systemd else udev)
148 libselinux
149 audit
150 libpsl
151 libuuid
152 polkit
153 ppp
154 libndp
155 curl
156 mobile-broadband-provider-info
157 bluez5
158 dnsmasq
159 modemmanager
160 readline
161 newt
162 jansson
163 dbus # used to get directory paths with pkg-config during configuration
164 ]
165 ++ lib.optionals withNbft [
166 libnvme
167 ];
168
169 propagatedBuildInputs = [
170 gnutls
171 libgcrypt
172 ];
173
174 nativeBuildInputs = [
175 meson
176 ninja
177 gettext
178 pkg-config
179 vala
180 gobject-introspection
181 perl
182 elfutils # used to find jansson soname
183 # Docs
184 gtk-doc
185 libxslt
186 docbook_xsl
187 docbook_xml_dtd_412
188 docbook_xml_dtd_42
189 docbook_xml_dtd_43
190 pythonForDocs
191 udevCheckHook
192 ]
193 ++ lib.optionals (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) [
194 mesonEmulatorHook
195 ];
196
197 doCheck = false; # requires /sys, the net
198
199 postPatch = ''
200 patchShebangs ./tools
201 patchShebangs libnm/generate-setting-docs.py
202
203 # TODO: submit upstream
204 substituteInPlace meson.build \
205 --replace "'vala', req" "'vala', native: false, req"
206 ''
207 + lib.optionalString withSystemd ''
208 substituteInPlace data/NetworkManager.service.in \
209 --replace-fail /usr/bin/busctl ${systemd}/bin/busctl
210 '';
211
212 preBuild = ''
213 # Our gobject-introspection patches make the shared library paths absolute
214 # in the GIR files. When building docs, the library is not yet installed,
215 # though, so we need to replace the absolute path with a local one during build.
216 # We are using a symlink that will be overridden during installation.
217 mkdir -p ${placeholder "out"}/lib
218 ln -s $PWD/src/libnm-client-impl/libnm.so.0 ${placeholder "out"}/lib/libnm.so.0
219 '';
220
221 postFixup = lib.optionalString (stdenv.buildPlatform != stdenv.hostPlatform) ''
222 cp -r ${buildPackages.networkmanager.devdoc} $devdoc
223 cp -r ${buildPackages.networkmanager.man} $man
224 '';
225
226 doInstallCheck = true;
227
228 passthru = {
229 updateScript = gitUpdater {
230 odd-unstable = true;
231 url = "https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git";
232 };
233 tests = {
234 inherit (nixosTests.networking) networkmanager;
235 };
236 };
237
238 meta = {
239 homepage = "https://networkmanager.dev";
240 description = "Network configuration and management tool";
241 license = lib.licenses.gpl2Plus;
242 changelog = "https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/raw/${finalAttrs.version}/NEWS";
243 maintainers = with lib.maintainers; [
244 obadz
245 ];
246 teams = [ lib.teams.freedesktop ];
247 platforms = lib.platforms.linux;
248 badPlatforms = [
249 # Mandatory shared libraries.
250 lib.systems.inspect.platformPatterns.isStatic
251 ];
252 };
253})