24 , gobject-introspection
49 , mobile-broadband-provider-info
55 , withSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd
59 pythonForDocs = python3.pythonOnBuildForHost.withPackages (pkgs: with pkgs; [ pygobject3 ]);
61 stdenv.mkDerivation rec {
62 pname = "networkmanager";
66 url = "mirror://gnome/sources/NetworkManager/${lib.versions.majorMinor version}/NetworkManager-${version}.tar.xz";
67 hash = "sha256-XcGI/f/PLSPInTSx5jGaayAgPhLq7CSzADe36orIxhM=";
70 outputs = [ "out" "dev" "devdoc" "man" "doc" ];
72 # Right now we hardcode quite a few paths at build time. Probably we should
73 # patch networkmanager to allow passing these path in config file. This will
74 # remove unneeded build-time dependencies.
78 "--localstatedir=/var"
79 (lib.mesonOption "systemdsystemunitdir"
80 (if withSystemd then "${placeholder "out"}/etc/systemd/system" else "no"))
81 # to enable link-local connections
82 "-Dudev_dir=${placeholder "out"}/lib/udev"
83 "-Ddbus_conf_dir=${placeholder "out"}/share/dbus-1/system.d"
84 "-Dkernel_firmware_dir=/run/current-system/firmware"
87 "-Dmodprobe=${kmod}/bin/modprobe"
88 (lib.mesonOption "session_tracking" (if withSystemd then "systemd" else "no"))
89 (lib.mesonBool "systemd_journal" withSystemd)
90 "-Dlibaudit=yes-disabled-by-default"
91 "-Dpolkit_agent_helper_1=/run/wrappers/bin/polkit-agent-helper-1"
94 # Allow using iwd when configured to do so
96 "-Dpppd=${ppp}/bin/pppd"
97 "-Diptables=${iptables}/bin/iptables"
98 "-Dnft=${nftables}/bin/nft"
99 "-Dmodem_manager=true"
101 "-Ddnsmasq=${dnsmasq}/bin/dnsmasq"
105 "-Dresolvconf=${openresolv}/bin/resolvconf"
108 # ISC DHCP client has reached it's end of life, so stop using it
110 "-Ddhcpcd=${dhcpcd}/bin/dhcpcd"
114 # almost cross-compiles, however fails with
115 # ** (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
116 "-Ddocs=${lib.boolToString (stdenv.buildPlatform == stdenv.hostPlatform)}"
117 # We don't use firewalld in NixOS
118 "-Dfirewalld_zone=false"
121 "-Dmobile_broadband_provider_info_database=${mobile-broadband-provider-info}/share/mobile-broadband-provider-info/serviceproviders.xml"
126 src = ./fix-paths.patch;
127 inherit iputils openconnect ethtool gnused systemd;
128 inherit runtimeShell;
131 # Meson does not support using different directories during build and
132 # for installation like Autotools did with flags passed to make install.
133 ./fix-install-paths.patch
135 # https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1966
136 ./without-systemd.patch
140 (if withSystemd then systemd else udev)
149 mobile-broadband-provider-info
157 dbus # used to get directory paths with pkg-config during configuration
160 propagatedBuildInputs = [ gnutls libgcrypt ];
162 nativeBuildInputs = [
168 gobject-introspection
170 elfutils # used to find jansson soname
179 ] ++ lib.optionals (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) [
183 doCheck = false; # requires /sys, the net
186 patchShebangs ./tools
187 patchShebangs libnm/generate-setting-docs.py
189 # TODO: submit upstream
190 substituteInPlace meson.build \
191 --replace "'vala', req" "'vala', native: false, req"
192 '' + lib.optionalString withSystemd ''
193 substituteInPlace data/NetworkManager.service.in \
194 --replace-fail /usr/bin/busctl ${systemd}/bin/busctl
198 # Our gobject-introspection patches make the shared library paths absolute
199 # in the GIR files. When building docs, the library is not yet installed,
200 # though, so we need to replace the absolute path with a local one during build.
201 # We are using a symlink that will be overridden during installation.
202 mkdir -p ${placeholder "out"}/lib
203 ln -s $PWD/src/libnm-client-impl/libnm.so.0 ${placeholder "out"}/lib/libnm.so.0
206 postFixup = lib.optionalString (stdenv.buildPlatform != stdenv.hostPlatform) ''
207 cp -r ${buildPackages.networkmanager.devdoc} $devdoc
208 cp -r ${buildPackages.networkmanager.man} $man
212 updateScript = gnome.updateScript {
213 packageName = "NetworkManager";
214 attrPath = "networkmanager";
215 versionPolicy = "odd-unstable";
218 inherit (nixosTests.networking) networkmanager;
223 homepage = "https://networkmanager.dev";
224 description = "Network configuration and management tool";
225 license = licenses.gpl2Plus;
226 changelog = "https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/raw/${version}/NEWS";
227 maintainers = teams.freedesktop.members ++ (with maintainers; [ domenkozar obadz ]);
228 platforms = platforms.linux;
230 # Mandatory shared libraries.
231 lib.systems.inspect.platformPatterns.isStatic