]> Git — Sourcephile - sourcephile-nix.git/blob - install/overlays/tools/networking/shorewall/default.nix
shorewall: fix packages for nixos-19.03
[sourcephile-nix.git] / install / overlays / tools / networking / shorewall / default.nix
1 { stdenv
2 , fetchurl
3 , perl
4 , perlPackages
5 , coreutils
6 , iproute
7 , ipset
8 , iptables
9 , ebtables
10 , shorewall-core
11 , utillinux
12 , gnugrep
13 , gnused
14 }:
15 let
16 PATH = stdenv.lib.concatStringsSep ":"
17 [ "${coreutils}/bin"
18 "${iproute}/bin"
19 "${iptables}/bin"
20 "${ipset}/bin"
21 "${ebtables}/bin"
22 "${utillinux}/bin"
23 "${gnugrep}/bin"
24 "${gnused}/bin"
25 ];
26 in
27 stdenv.mkDerivation rec {
28 baseName = "shorewall";
29 version = "5.2.0.5";
30 name = "${baseName}-${version}";
31
32 src = fetchurl {
33 url = "http://www.shorewall.net/pub/shorewall/5.2/shorewall-5.2.0/${baseName}-${version}.tar.bz2";
34 sha256 = "005qv6kybk1jn1i63rchf86kwbxwwn463cxkp03q0mpc0cnj018w";
35 };
36
37 buildInputs = [
38 coreutils
39 iproute
40 ipset
41 iptables
42 ebtables
43 shorewall-core
44 utillinux
45 gnugrep
46 gnused
47 perl
48 ] ++ (with perlPackages; [
49 DigestSHA1
50 ]);
51 configurePhase = ''
52 substituteInPlace ./configure --replace '#!/bin/bash' ${stdenv.shell}
53 PATH=$PATH:${shorewall-core}/bin \
54 ./configure \
55 HOST=linux \
56 PREFIX=$out \
57 CONFDIR=\$PREFIX/etc \
58 SBINDIR=\$PREFIX/sbin \
59 SYSCONFDIR=\$PREFIX/etc/default \
60 VARLIB=/var/lib \
61 INITSOURCE= \
62 INITDIR= \
63 INITFILE= \
64 DEFAULT_PAGER=
65 '';
66 installPhase = ''
67 # Merge with shorewall-core
68 cp -r -s ${shorewall-core} $out
69 chmod u+w $out $out/*/ $out/*/*/ $out/*/*/*/
70 ln -fns bin $out/sbin
71 # Install shorewallrc and shorewall
72 cp --remove-destination shorewallrc $out/share/shorewall/
73 substituteInPlace ./install.sh --replace '#!/bin/sh' ${stdenv.shell}
74 ./install.sh
75 cp ${shorewall-core}/sbin/shorewall $out/sbin/shorewall4
76 ln -fns shorewall4 $out/sbin/shorewall
77 # Actual config will be expected in /etc/shorewall
78 sed -i $out/share/shorewall/shorewallrc \
79 -e 's~^CONFDIR=.*~CONFDIR=/etc~'
80 # Fix PATH
81 sed -i $out/sbin/shorewall \
82 -e 's~^\. ${shorewall-core}\(/share/shorewall/shorewallrc\)~. '$out'\1~' \
83 -e 's~^PRODUCT=.*~&\nexport PATH=${PATH}''${PATH:+:}$PATH~'
84 # Fix shorewall.conf
85 sed -i $out/etc/shorewall/shorewall.conf \
86 -e 's|^LOGFILE=.*|LOGFILE=/var/log/shorewall.log|' \
87 -e 's|^PATH=.*|PATH=${PATH}|' \
88 -e 's|^PERL=.*|PERL=${perl}/bin/perl|' \
89 -e 's|^SHOREWALL_SHELL=.*|SHOREWALL_SHELL=${stdenv.shell}|'
90 # FIXME: the default GEOIPDIR=/usr/share/xt_geoip/LE may require attention.
91 '';
92
93 meta = {
94 homepage = http://www.shorewall.net/;
95 description = "An IPv4 gateway/firewall configuration tool for GNU/Linux";
96 longDescription = ''
97 Shorewall is a high-level tool for configuring Netfilter. You describe your
98 firewall/gateway requirements using entries in a set of configuration
99 files. Shorewall reads those configuration files and with the help of the
100 iptables, iptables-restore, ip and tc utilities, Shorewall configures
101 Netfilter and the Linux networking subsystem to match your requirements.
102 Shorewall can be used on a dedicated firewall system, a multi-function
103 gateway/router/server or on a standalone GNU/Linux system. Shorewall does
104 not use Netfilter's ipchains compatibility mode and can thus take
105 advantage of Netfilter's connection state tracking capabilities.
106 '';
107 license = stdenv.lib.licenses.gpl2Plus;
108 platforms = stdenv.lib.platforms.linux;
109 };
110 }