2021-01-19 06:50:56 +00:00
|
|
|
{ lib, stdenv, fetchurl, pkg-config, pruneLibtoolFiles, flex, bison
|
2019-08-19 17:20:27 +00:00
|
|
|
, libmnl, libnetfilter_conntrack, libnfnetlink, libnftnl, libpcap
|
2020-02-27 10:47:33 +00:00
|
|
|
, nftablesCompat ? true
|
2022-05-15 08:51:48 +00:00
|
|
|
, fetchpatch
|
2019-08-19 17:20:27 +00:00
|
|
|
}:
|
|
|
|
|
2009-07-23 18:16:24 +00:00
|
|
|
stdenv.mkDerivation rec {
|
2022-05-15 08:51:48 +00:00
|
|
|
version = "1.8.8";
|
2019-08-19 17:20:27 +00:00
|
|
|
pname = "iptables";
|
2008-08-15 09:49:43 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
2019-05-28 22:17:46 +00:00
|
|
|
url = "https://www.netfilter.org/projects/${pname}/files/${pname}-${version}.tar.bz2";
|
2022-05-15 08:51:48 +00:00
|
|
|
sha256 = "sha256-ccdYidxxBnZjFVPrFRHaAXe7qvG1USZbkS0jbD9RhZ8=";
|
2008-08-15 09:49:43 +00:00
|
|
|
};
|
|
|
|
|
2022-05-15 08:51:48 +00:00
|
|
|
patches = [
|
|
|
|
# xshared: Fix build for -Werror=format-security
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://git.netfilter.org/iptables/patch/?id=b72eb12ea5a61df0655ad99d5048994e916be83a";
|
|
|
|
sha256 = "sha256-pnamqOagwNWoiwlxPnKCqSc2N7MP/eZlT7JiE09c8OE=";
|
|
|
|
})
|
|
|
|
# treewide: use uint* instead of u_int*
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://git.netfilter.org/iptables/patch/?id=f319389525b066b7dc6d389c88f16a0df3b8f189";
|
|
|
|
sha256 = "sha256-rOxCEWZoI8Ac5fQDp286YHAwvreUAoDVAbomboKrGyM=";
|
|
|
|
})
|
2022-06-29 12:38:02 +00:00
|
|
|
# fix Musl build
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://git.netfilter.org/iptables/patch/?id=0e7cf0ad306cdf95dc3c28d15a254532206a888e";
|
|
|
|
sha256 = "18mnvqfxzd7ifq3zjb4vyifcyadpxdi8iqcj8wsjgw23n49lgrbj";
|
|
|
|
})
|
2022-05-15 08:51:48 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
outputs = [ "out" "dev" "man" ];
|
|
|
|
|
2021-01-19 06:50:56 +00:00
|
|
|
nativeBuildInputs = [ pkg-config pruneLibtoolFiles flex bison ];
|
2016-01-01 01:54:56 +00:00
|
|
|
|
2019-08-19 17:20:27 +00:00
|
|
|
buildInputs = [ libmnl libnetfilter_conntrack libnfnetlink libnftnl libpcap ];
|
2016-01-01 01:54:56 +00:00
|
|
|
|
|
|
|
preConfigure = ''
|
|
|
|
export NIX_LDFLAGS="$NIX_LDFLAGS -lmnl -lnftnl"
|
|
|
|
'';
|
|
|
|
|
2018-07-25 21:44:21 +00:00
|
|
|
configureFlags = [
|
2019-08-19 17:20:27 +00:00
|
|
|
"--enable-bpf-compiler"
|
2018-07-25 21:44:21 +00:00
|
|
|
"--enable-devel"
|
2019-08-19 17:20:27 +00:00
|
|
|
"--enable-libipq"
|
|
|
|
"--enable-nfsynproxy"
|
2018-07-25 21:44:21 +00:00
|
|
|
"--enable-shared"
|
2022-05-15 08:51:48 +00:00
|
|
|
] ++ lib.optional (!nftablesCompat) "--disable-nftables";
|
2017-01-22 01:20:00 +00:00
|
|
|
|
2022-05-15 08:51:48 +00:00
|
|
|
postInstall = lib.optionalString nftablesCompat ''
|
2019-08-19 17:20:27 +00:00
|
|
|
rm $out/sbin/{iptables,iptables-restore,iptables-save,ip6tables,ip6tables-restore,ip6tables-save}
|
|
|
|
ln -sv xtables-nft-multi $out/bin/iptables
|
|
|
|
ln -sv xtables-nft-multi $out/bin/iptables-restore
|
|
|
|
ln -sv xtables-nft-multi $out/bin/iptables-save
|
|
|
|
ln -sv xtables-nft-multi $out/bin/ip6tables
|
|
|
|
ln -sv xtables-nft-multi $out/bin/ip6tables-restore
|
|
|
|
ln -sv xtables-nft-multi $out/bin/ip6tables-save
|
|
|
|
'';
|
|
|
|
|
2022-05-15 08:51:48 +00:00
|
|
|
meta = with lib; {
|
2008-08-15 09:49:43 +00:00
|
|
|
description = "A program to configure the Linux IP packet filtering ruleset";
|
2020-04-01 01:11:51 +00:00
|
|
|
homepage = "https://www.netfilter.org/projects/iptables/index.html";
|
2017-01-22 01:20:00 +00:00
|
|
|
platforms = platforms.linux;
|
|
|
|
maintainers = with maintainers; [ fpletz ];
|
2018-08-29 22:34:22 +00:00
|
|
|
license = licenses.gpl2;
|
2018-11-29 21:44:29 +00:00
|
|
|
downloadPage = "https://www.netfilter.org/projects/iptables/files/";
|
2008-08-15 09:49:43 +00:00
|
|
|
};
|
|
|
|
}
|