1{ lib, stdenv
2, fetchgit
3, autoreconfHook
4, pkg-config
5, ell
6, coreutils
7, docutils
8, readline
9, openssl
10, python3Packages
11, gitUpdater
12}:
13
14stdenv.mkDerivation rec {
15 pname = "iwd";
16 version = "2.19";
17
18 src = fetchgit {
19 url = "https://git.kernel.org/pub/scm/network/wireless/iwd.git";
20 rev = version;
21 hash = "sha256-LIzcV8OvtHItMpgFVHDQhUisD3kaMPMESd3cgOaIu/8=";
22 };
23
24 outputs = [ "out" "man" "doc" ]
25 ++ lib.optional (stdenv.hostPlatform == stdenv.buildPlatform) "test";
26
27 nativeBuildInputs = [
28 autoreconfHook
29 docutils
30 pkg-config
31 python3Packages.wrapPython
32 ];
33
34 buildInputs = [
35 ell
36 python3Packages.python
37 readline
38 ];
39
40 nativeCheckInputs = [ openssl ];
41
42 # wrapPython wraps the scripts in $test. They pull in gobject-introspection,
43 # which doesn't cross-compile.
44 pythonPath = lib.optionals (stdenv.hostPlatform == stdenv.buildPlatform) [
45 python3Packages.dbus-python
46 python3Packages.pygobject3
47 ];
48
49 configureFlags = [
50 "--enable-external-ell"
51 "--enable-wired"
52 "--localstatedir=/var/"
53 "--with-dbus-busdir=${placeholder "out"}/share/dbus-1/system-services/"
54 "--with-dbus-datadir=${placeholder "out"}/share/"
55 "--with-systemd-modloaddir=${placeholder "out"}/etc/modules-load.d/" # maybe
56 "--with-systemd-unitdir=${placeholder "out"}/lib/systemd/system/"
57 "--with-systemd-networkdir=${placeholder "out"}/lib/systemd/network/"
58 ];
59
60 postUnpack = ''
61 mkdir -p iwd/ell
62 ln -s ${ell.src}/ell/useful.h iwd/ell/useful.h
63 ln -s ${ell.src}/ell/asn1-private.h iwd/ell/asn1-private.h
64 patchShebangs .
65 '';
66
67 doCheck = true;
68
69 postInstall = ''
70 mkdir -p $doc/share/doc
71 cp -a doc $doc/share/doc/iwd
72 cp -a README AUTHORS TODO $doc/share/doc/iwd
73 '' + lib.optionalString (stdenv.hostPlatform == stdenv.buildPlatform) ''
74 mkdir -p $test/bin
75 cp -a test/* $test/bin/
76 '';
77
78 preFixup = ''
79 wrapPythonPrograms
80 '';
81
82 postFixup = ''
83 substituteInPlace $out/share/dbus-1/system-services/net.connman.ead.service \
84 --replace-fail /bin/false ${coreutils}/bin/false
85 substituteInPlace $out/share/dbus-1/system-services/net.connman.iwd.service \
86 --replace-fail /bin/false ${coreutils}/bin/false
87 '';
88
89 enableParallelBuilding = true;
90
91 passthru.updateScript = gitUpdater {
92 # No nicer place to find latest release.
93 url = "https://git.kernel.org/pub/scm/network/wireless/iwd.git";
94 };
95
96 meta = with lib; {
97 homepage = "https://git.kernel.org/pub/scm/network/wireless/iwd.git";
98 description = "Wireless daemon for Linux";
99 license = licenses.lgpl21Plus;
100 platforms = platforms.linux;
101 maintainers = with maintainers; [ dtzWill fpletz ];
102 };
103}