summary refs log tree commit diff
path: root/pkgs/applications/networking/firewalld/default.nix
blob: 5a7dc544bf19d441aada213ad0544639aaee8c74 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
{ lib
, stdenv
, fetchFromGitHub
, autoreconfHook
, bash
, docbook_xml_dtd_42
, docbook-xsl-nons
, glib
, gobject-introspection
, gtk3
, intltool
, libnotify
, libxml2
, libxslt
, networkmanagerapplet
, pkg-config
, python3
, wrapGAppsNoGuiHook
, withGui ? false
}:

let
  pythonPath = python3.withPackages (ps: with ps; [
    dbus-python
    nftables
    pygobject3
  ] ++ lib.optionals withGui [
    pyqt5
    pyqt5_sip
  ]);
in
stdenv.mkDerivation rec {
  pname = "firewalld";
  version = "2.0.0";

  src = fetchFromGitHub {
    owner = "firewalld";
    repo = "firewalld";
    rev = "v${version}";
    sha256 = "sha256-seOokeFbjCuwUsB6MbrxaeTlPUzwNzkJPbByM9/oDDU=";
  };

  patches = [
    ./respect-xml-catalog-files-var.patch
  ];

  postPatch = ''
    substituteInPlace src/firewall/config/__init__.py.in \
      --replace "/usr/share" "$out/share"

    for file in config/firewall-{applet,config}.desktop.in; do
      substituteInPlace $file \
        --replace "/usr/bin/" "$out/bin/"
    done
  '' + lib.optionalString withGui ''
    substituteInPlace src/firewall-applet.in \
      --replace "/usr/bin/nm-connection-editor" "${networkmanagerapplet}/bin/nm-conenction-editor"
  '';

  nativeBuildInputs = [
    autoreconfHook
    docbook_xml_dtd_42
    docbook-xsl-nons
    glib
    intltool
    libxml2
    libxslt
    pkg-config
    python3
    python3.pkgs.wrapPython
  ] ++ lib.optionals withGui [
    gobject-introspection
    wrapGAppsNoGuiHook
  ];

  buildInputs = [
    bash
    glib
  ] ++ lib.optionals withGui [
    gtk3
    libnotify
    pythonPath
  ];

  dontWrapGApps = true;

  preFixup = lib.optionalString withGui ''
    makeWrapperArgs+=("''${gappsWrapperArgs[@]}")
  '';

  postFixup = ''
    chmod +x $out/share/firewalld/*.py $out/share/firewalld/testsuite/python/*.py $out/share/firewalld/testsuite/{,integration/}testsuite
    patchShebangs --host $out/share/firewalld/testsuite/{,integration/}testsuite $out/share/firewalld/*.py
    wrapPythonProgramsIn "$out/bin" "$out ${pythonPath}"
    wrapPythonProgramsIn "$out/share/firewalld/testsuite/python" "$out ${pythonPath}"
  '';

  meta = with lib; {
    description = "Firewall daemon with D-Bus interface";
    homepage = "https://github.com/firewalld/firewalld";
    license = licenses.gpl2Plus;
    maintainers = with maintainers; [ ];
  };
}