nixpkgs/pkgs/by-name/za/zapret/package.nix
2024-11-01 13:48:13 +03:00

87 lines
2.1 KiB
Nix

{
lib,
stdenv,
fetchFromGitHub,
libcap,
zlib,
libnetfilter_queue,
libnfnetlink,
iptables,
nftables,
gawk
}:
stdenv.mkDerivation (finalAttrs: {
pname = "zapret";
version = "67";
src = fetchFromGitHub {
owner = "bol-van";
repo = "zapret";
rev = "refs/tags/v${finalAttrs.version}";
hash = "sha256-4TgM0NkvVvdSEJ01SULu+GqpfqokTTErHAt3QkxkLIs=";
};
buildInputs = [ libcap zlib libnetfilter_queue libnfnetlink ];
nativeBuildInputs = [ iptables nftables gawk ];
makeFlags = [ "TGT=${placeholder "out"}/bin" ];
installPhase = ''
runHook preInstall
mkdir -p $out/usr/share/zapret/init.d/sysv
mkdir -p $out/usr/share/docs
cp $src/blockcheck.sh $out/bin/blockcheck
substituteInPlace $out/bin/blockcheck \
--replace-fail '$(cd "$EXEDIR"; pwd)' "$out/usr/share/zapret"
ln -s ../../../bin/blockcheck $out/usr/share/zapret/blockcheck
cp $src/init.d/sysv/functions $out/usr/share/zapret/init.d/sysv/functions
cp $src/init.d/sysv/zapret $out/usr/share/zapret/init.d/sysv/init.d
substituteInPlace $out/usr/share/zapret/init.d/sysv/functions \
--replace-fail "/opt/zapret" "\"$out/usr/share/zapret\""
touch $out/usr/share/zapret/config
cp -r $src/docs/* $out/usr/share/docs
mkdir -p $out/usr/share/zapret/{common,ipset}
cp $src/common/* $out/usr/share/zapret/common
cp $src/ipset/* $out/usr/share/zapret/ipset
rm -f $out/usr/share/zapret/ipset/zapret-hosts-user-exclude.txt.default
mkdir -p $out/usr/share/zapret/nfq
ln -s ../../../../bin/nfqws $out/usr/share/zapret/nfq/nfqws
for i in ip2net mdig tpws
do
mkdir -p $out/usr/share/zapret/$i
ln -s ../../../../bin/$i $out/usr/share/zapret/$i/$i
done
ln -s ../usr/share/zapret/init.d/sysv/init.d $out/bin/zapret
runHook postInstall
'';
meta = {
description = "DPI bypass multi platform";
homepage = "https://github.com/bol-van/zapret";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ nishimara ];
mainProgram = "zapret";
# probably gonna work on darwin, but untested
broken = stdenv.hostPlatform.isDarwin;
};
})