nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchFromGitLab,
5 fetchpatch,
6 installShellFiles,
7 python3Packages,
8 asciidoc,
9 wrapGAppsNoGuiHook,
10 iw,
11}:
12
13stdenv.mkDerivation rec {
14 pname = "networkd-dispatcher";
15 version = "2.2.4";
16
17 src = fetchFromGitLab {
18 domain = "gitlab.com";
19 owner = "craftyguy";
20 repo = "networkd-dispatcher";
21 rev = version;
22 hash = "sha256-yO9/HlUkaQmW/n9N3vboHw//YMzBjxIHA2zAxgZNEv0=";
23 };
24
25 patches = [
26 # Support rule files in NixOS store paths. Required for the networkd-dispatcher
27 # module to work
28 ./support_nix_store_path.patch
29
30 # Fixes: networkd-dispatcher.service: Got notification message from PID XXXX, but reception only permitted for main PID XXXX
31 (fetchpatch {
32 url = "https://gitlab.com/craftyguy/networkd-dispatcher/-/commit/4796368d88da516fafda321d8565ae8ccf465120.patch";
33 hash = "sha256-RAoCSmZCjTXxVKesatWjiePY4xECGn5pwvOOV0clL+Q=";
34 })
35 ];
36
37 postPatch = ''
38 # Fix paths in systemd unit file
39 substituteInPlace networkd-dispatcher.service \
40 --replace-fail "/usr/bin/networkd-dispatcher" "$out/bin/networkd-dispatcher"
41 # Remove conditions on existing rules path
42 sed -i '/ConditionPathExistsGlob/g' networkd-dispatcher.service
43 '';
44
45 nativeBuildInputs = [
46 asciidoc # for a2x
47 installShellFiles
48 wrapGAppsNoGuiHook
49 python3Packages.wrapPython
50 ];
51
52 dontWrapGApps = true;
53
54 checkInputs = with python3Packages; [
55 dbus-python
56 iw
57 mock
58 pygobject3
59 pytestCheckHook
60 ];
61
62 pythonPath = with python3Packages; [
63 dbus-python
64 pygobject3
65 ];
66
67 installPhase = ''
68 runHook preInstall
69 install -D -m755 -t $out/bin networkd-dispatcher
70 install -Dm644 networkd-dispatcher.service $out/lib/systemd/system/networkd-dispatcher.service
71 install -Dm644 networkd-dispatcher.conf $out/etc/conf.d/networkd-dispatcher.conf
72 installManPage networkd-dispatcher.8
73 runHook postInstall
74 '';
75
76 doCheck = true;
77
78 preFixup = ''
79 makeWrapperArgs+=( \
80 "''${gappsWrapperArgs[@]}" \
81 --prefix PATH : "${lib.makeBinPath [ iw ]}" \
82 )
83 '';
84 postFixup = ''
85 wrapPythonPrograms
86 '';
87
88 meta = with lib; {
89 description = "Dispatcher service for systemd-networkd connection status changes";
90 mainProgram = "networkd-dispatcher";
91 homepage = "https://gitlab.com/craftyguy/networkd-dispatcher";
92 license = licenses.gpl3Only;
93 platforms = platforms.linux;
94 maintainers = with maintainers; [ onny ];
95 };
96}