@@ -0,0 +1,104 @@
1+{ lib
2+, stdenv
3+, fetchFromGitHub
4+, autoreconfHook
5+, bash
6+, docbook_xml_dtd_42
7+, docbook-xsl-nons
8+, glib
9+, gobject-introspection
10+, gtk3
11+, intltool
12+, libnotify
13+, libxml2
14+, libxslt
15+, networkmanager-applet
16+, pkg-config
17+, python3
18+, wrapGAppsNoGuiHook
19+, withGui ? false
20+}:
21+
22+let
23+ pythonPath = python3.withPackages (ps: with ps; [
24+ dbus-python
25+ nftables
26+ pygobject3
27+ ] ++ lib.optionals withGui [
28+ pyqt5
29+ pyqt5_sip
30+ ]);
31+in
32+stdenv.mkDerivation rec {
33+ pname = "firewalld";
34+ version = "1.1.1";
35+
36+ src = fetchFromGitHub {
37+ owner = "firewalld";
38+ repo = "firewalld";
39+ rev = "v${version}";
40+ sha256 = "sha256-w8TbovIhOhJAUZWbKdBd/+db8Hro/ttlxWZDcrCXX4Q=";
41+ };
42+
43+ patches = [
44+ ./respect-xml-catalog-files-var.patch
45+ ];
46+
47+ postPatch = ''
48+ substituteInPlace src/firewall/config/__init__.py.in \
49+ --replace "/usr/share" "$out/share"
50+
51+ for file in config/firewall-{applet,config}.desktop.in; do
52+ substituteInPlace $file \
53+ --replace "/usr/bin/" "$out/bin/"
54+ done
55+ '' + lib.optionalString withGui ''
56+ substituteInPlace src/firewall-applet.in \
57+ --replace "/usr/bin/nm-connection-editor" "${networkmanager-applet}/bin/nm-conenction-editor"
58+ '';
59+
60+ nativeBuildInputs = [
61+ autoreconfHook
62+ docbook_xml_dtd_42
63+ docbook-xsl-nons
64+ glib
65+ intltool
66+ libxml2
67+ libxslt
68+ pkg-config
69+ python3
70+ python3.pkgs.wrapPython
71+ ] ++ lib.optionals withGui [
72+ gobject-introspection
73+ wrapGAppsNoGuiHook
74+ ];
75+
76+ buildInputs = [
77+ bash
78+ glib
79+ ] ++ lib.optionals withGui [
80+ gtk3
81+ libnotify
82+ pythonPath
83+ ];
84+
85+ dontWrapGApps = true;
86+
87+ preFixup = lib.optionalString withGui ''
88+ makeWrapperArgs+=("''${gappsWrapperArgs[@]}")
89+ '';
90+
91+ postFixup = ''
92+ chmod +x $out/share/firewalld/*.py $out/share/firewalld/testsuite/python/*.py $out/share/firewalld/testsuite/{,integration/}testsuite
93+ patchShebangs --host $out/share/firewalld/testsuite/{,integration/}testsuite $out/share/firewalld/*.py
94+ wrapPythonProgramsIn "$out/bin" "$out ${pythonPath}"
95+ wrapPythonProgramsIn "$out/share/firewalld/testsuite/python" "$out ${pythonPath}"
96+ '';
97+
98+ meta = with lib; {
99+ description = "Firewall daemon with D-Bus interface";
100+ homepage = "https://github.com/firewalld/firewalld";
101+ license = licenses.gpl2Plus;
102+ maintainers = with maintainers; [ SuperSandro2000 ];
103+ };
104+}