]> Git — Sourcephile - sourcephile-nix.git/blob - pkgs/tools/networking/shorewall/default.nix
nix: fix cd in .envrc
[sourcephile-nix.git] / pkgs / tools / networking / shorewall / default.nix
1 { coreutils
2 , ebtables
3 , fetchurl
4 , gnugrep
5 , gnused
6 , iproute
7 , ipset
8 , iptables
9 , perl
10 , perlPackages
11 , stdenv
12 , tree
13 , utillinux
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.3.3";
30 name = "${baseName}-${version}";
31
32 srcs = [
33 (fetchurl {
34 url = "http://www.shorewall.net/pub/shorewall/5.2/shorewall-5.2.3/shorewall-core-${version}.tar.bz2";
35 sha256 = "1gg2yfxzm3y9qqjrrg5nq2ggi1c6yfxx0s7fvwjw70b185mwa5p5";
36 })
37 (fetchurl {
38 url = "http://www.shorewall.net/pub/shorewall/5.2/shorewall-5.2.3/shorewall-${version}.tar.bz2";
39 sha256 = "1ka70pa3s0cnvc83rlm57r05cdv9idnxnq0vmxi6nr7razak5f3b";
40 })
41 (fetchurl {
42 url = "http://www.shorewall.net/pub/shorewall/5.2/shorewall-5.2.3/shorewall6-${version}.tar.bz2";
43 sha256 = "0mhs4m6agwk082h1n69gnyfsjpycdd8215r4r9rzb3czs5xi087n";
44 })
45 ];
46 sourceRoot = ".";
47
48 buildInputs = [
49 coreutils
50 iproute
51 ipset
52 iptables
53 ebtables
54 utillinux
55 gnugrep
56 gnused
57 perl
58 ] ++ (with perlPackages; [
59 DigestSHA1
60 ]);
61 prePatch = ''
62 # Patch configure and install.sh files
63 patchShebangs .
64
65 # Remove hardcoded PATH
66 sed -i shorewall-core-${version}/lib.cli \
67 -e '/^ *PATH=.*/d'
68 '';
69 configurePhase = ''
70 shorewall-core-${version}/configure \
71 HOST=linux \
72 PREFIX=$out \
73 CONFDIR=\$PREFIX/etc-example \
74 SBINDIR=\$PREFIX/sbin \
75 SYSCONFDIR= \
76 SHAREDIR=\$PREFIX/share \
77 LIBEXECDIR=\$SHAREDIR \
78 PERLLIBDIR=\$SHAREDIR/shorewall \
79 MANDIR=$out/man \
80 VARLIB=/var/lib \
81 INITSOURCE= \
82 INITDIR= \
83 INITFILE= \
84 DEFAULT_PAGER=
85 '';
86 installPhase = ''
87 export DESTDIR=/
88 shorewall-core-${version}/install.sh
89
90 ln -s ../shorewall-core-${version}/shorewallrc shorewall-${version}/
91 shorewall-${version}/install.sh
92
93 ln -s ../shorewall-core-${version}/shorewallrc shorewall6-${version}/
94 shorewall6-${version}/install.sh
95
96 # Patch the example shorewall{,6}.conf in case it is included
97 # in services.shorewall{,6}.configs
98 sed -i $out/etc-example/shorewall/shorewall.conf \
99 $out/etc-example/shorewall6/shorewall6.conf \
100 -e 's|^LOGFILE=.*|LOGFILE=/var/log/shorewall.log|' \
101 -e 's|^PATH=.*|PATH=${PATH}|' \
102 -e 's|^PERL=.*|PERL=${perl}/bin/perl|' \
103 -e 's|^SHOREWALL_SHELL=.*|SHOREWALL_SHELL=${stdenv.shell}|'
104 sed -i $out/etc-example/shorewall6/shorewall6.conf \
105 -e 's|^CONFIG_PATH=.*|CONFIG_PATH=:''${CONFDIR}/shorewall6:''${SHAREDIR}/shorewall6:''${SHAREDIR}/shorewall|'
106 # FIXME: the default GEOIPDIR=/usr/share/xt_geoip/LE may require attention.
107
108 # Redirect CONFDIR to /etc where services.shorewall{,6}.configs
109 # will generate the config files.
110 sed -i $out/share/shorewall/shorewallrc \
111 -e 's~^CONFDIR=.*~CONFDIR=/etc~'
112 '';
113
114 meta = {
115 homepage = http://www.shorewall.net/;
116 description = "An IPv4 gateway/firewall configuration tool for GNU/Linux";
117 longDescription = ''
118 Shorewall is a high-level tool for configuring Netfilter. You describe your
119 firewall/gateway requirements using entries in a set of configuration
120 files. Shorewall reads those configuration files and with the help of the
121 iptables, iptables-restore, ip and tc utilities, Shorewall configures
122 Netfilter and the Linux networking subsystem to match your requirements.
123 Shorewall can be used on a dedicated firewall system, a multi-function
124 gateway/router/server or on a standalone GNU/Linux system. Shorewall does
125 not use Netfilter's ipchains compatibility mode and can thus take
126 advantage of Netfilter's connection state tracking capabilities.
127 '';
128 license = stdenv.lib.licenses.gpl2Plus;
129 platforms = stdenv.lib.platforms.linux;
130 };
131 }