nixpkgs/pkgs/tools/networking/network-manager/default.nix
Jan Tojnar a961a289a9
networkmanager: port to Meson
All hail Meson!

One serious issue is that building docs does not work.

We patch gobject-introspection to use absolute paths for shared libraries
in GIR files. Building the NetworkManager docs relies on the produced
introspection data but since the library is not yet installed
at the time the docs are generated, the build will fail.

It works in Autotools for some reason; they probably use
the pregenerated GIRs from the tarball.

Disabling the docs completely is not possible at the moment either,
since nmc [depends on them][1].

I have decided to fix this by pointing the installed location to the one
in the build directory using libredirect. Unfortunately, we cannot just set
the environment variables directly, since the build system runs
the documentation generator in a clean environment.

I have also added man, doc and devdoc outputs so the generated files have
somewhere to go.

Secondly, since Nix store is immutable, we also cannot use the package prefix
for configuration and mutable state data. At the same time, we cannot write
to the appropriate global directories during build. Autotools allowed to change
this in installFlags but Meson lacks similar mechanism so we need to patch
the build files.

Finally, I also removed the at_console patch since the permission has been
removed in 0.9.10.

[1]: https://bugzilla.gnome.org/show_bug.cgi?id=796755
2019-04-22 12:10:10 +02:00

123 lines
4.6 KiB
Nix

{ stdenv, fetchurl, substituteAll, intltool, pkgconfig, dbus, dbus-glib
, gnome3, systemd, libuuid, polkit, gnutls, ppp, dhcp, iptables, python3, vala
, libgcrypt, dnsmasq, bluez5, readline, libselinux, audit
, gobject-introspection, modemmanager, openresolv, libndp, newt, libsoup
, ethtool, gnused, coreutils, inetutils, kmod, jansson, gtk-doc, libxslt
, docbook_xsl, docbook_xml_dtd_412, docbook_xml_dtd_42, docbook_xml_dtd_43
, openconnect, curl, meson, ninja, libpsl, libredirect }:
let
pname = "NetworkManager";
pythonForDocs = python3.withPackages (pkgs: with pkgs; [ pygobject3 ]);
in stdenv.mkDerivation rec {
name = "network-manager-${version}";
version = "1.16.0";
src = fetchurl {
url = "mirror://gnome/sources/${pname}/${stdenv.lib.versions.majorMinor version}/${pname}-${version}.tar.xz";
sha256 = "0b2x9hrg41cd17psqi0vacwj733v99hxczn53gdfs0yanqrji5lf";
};
outputs = [ "out" "dev" "devdoc" "man" "doc" ];
# Right now we hardcode quite a few paths at build time. Probably we should
# patch networkmanager to allow passing these path in config file. This will
# remove unneeded build-time dependencies.
mesonFlags = [
"-Ddhclient=${dhcp}/bin/dhclient"
"-Ddnsmasq=${dnsmasq}/bin/dnsmasq"
# Upstream prefers dhclient, so don't add dhcpcd to the closure
"-Ddhcpcd=no"
"-Dpppd=${ppp}/bin/pppd"
"-Diptables=${iptables}/bin/iptables"
# to enable link-local connections
"-Dudev_dir=${placeholder "out"}/lib/udev"
"-Dresolvconf=${openresolv}/bin/resolvconf"
"-Ddbus_conf_dir=${placeholder "out"}/etc/dbus-1/system.d"
"-Dsystemdsystemunitdir=${placeholder "out"}/etc/systemd/system"
"-Dkernel_firmware_dir=/run/current-system/firmware"
"--sysconfdir=/etc"
"--localstatedir=/var"
"-Dcrypto=gnutls"
"-Dsession_tracking=systemd"
"-Dmodem_manager=true"
"-Dnmtui=true"
"-Ddocs=true"
"-Dlibnm_glib=true" # legacy library, TODO: remove
"-Dtests=no"
"-Dqt=false"
];
patches = [
(substituteAll {
src = ./fix-paths.patch;
inherit inetutils kmod openconnect ethtool coreutils dbus;
inherit (stdenv) shell;
})
# Meson does not support using different directories during build and
# for installation like Autotools did with flags passed to make install.
./fix-install-paths.patch
# Our gobject-introspection patches make the shared library paths absolute
# in the GIR files. When building docs, the library is not yet installed,
# though, so we need to replace the absolute path with a local one during build.
# We are replacing the variables in postPatch since substituteAll does not support
# placeholders.
./fix-docs-build.patch
];
buildInputs = [
systemd libselinux audit libpsl libuuid polkit ppp libndp curl
bluez5 dnsmasq gobject-introspection modemmanager readline newt libsoup jansson
];
propagatedBuildInputs = [ dbus-glib gnutls libgcrypt ];
nativeBuildInputs = [
meson ninja intltool pkgconfig
vala gobject-introspection
dbus-glib # for dbus-binding-tool
# Docs
gtk-doc libxslt docbook_xsl docbook_xml_dtd_412 docbook_xml_dtd_42 docbook_xml_dtd_43 pythonForDocs
];
doCheck = false; # requires /sys, the net
postPatch = ''
patchShebangs ./tools
patchShebangs libnm/generate-setting-docs.py
substituteInPlace libnm/meson.build \
--subst-var-by DOCS_LD_PRELOAD "${libredirect}/lib/libredirect.so" \
--subst-var-by DOCS_NIX_REDIRECTS "${placeholder "out"}/lib/libnm.so.0=$PWD/build/libnm/libnm.so.0"
'';
postInstall = ''
# systemd in NixOS doesn't use `systemctl enable`, so we need to establish
# aliases ourselves.
ln -s $out/etc/systemd/system/NetworkManager-dispatcher.service $out/etc/systemd/system/dbus-org.freedesktop.nm-dispatcher.service
ln -s $out/etc/systemd/system/NetworkManager.service $out/etc/systemd/system/dbus-org.freedesktop.NetworkManager.service
# Add the legacy service name from before #51382 to prevent NetworkManager
# from not starting back up:
# TODO: remove this once 19.10 is released
ln -s $out/etc/systemd/system/NetworkManager.service $out/etc/systemd/system/network-manager.service
'';
passthru = {
updateScript = gnome3.updateScript {
packageName = pname;
attrPath = "networkmanager";
};
};
meta = with stdenv.lib; {
homepage = https://wiki.gnome.org/Projects/NetworkManager;
description = "Network configuration and management tool";
license = licenses.gpl2Plus;
maintainers = with maintainers; [ phreedom rickynils domenkozar obadz ];
platforms = platforms.linux;
};
}