nixpkgs/pkgs/by-name/za/zapret/package.nix
Silvan Mosberger 4f0dadbf38 treewide: format all inactive Nix files
After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.

Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.

A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.

This commit was automatically created and can be verified using

    nix-build a08b3a4d19.tar.gz \
      --argstr baseRev b32a094368
    result/bin/apply-formatting $NIXPKGS_PATH
2024-12-10 20:26:33 +01:00

100 lines
2.3 KiB
Nix

{
lib,
stdenv,
fetchFromGitHub,
nix-update-script,
libcap,
zlib,
libnetfilter_queue,
libnfnetlink,
iptables,
nftables,
gawk,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "zapret";
version = "69.5";
src = fetchFromGitHub {
owner = "bol-van";
repo = "zapret";
rev = "refs/tags/v${finalAttrs.version}";
hash = "sha256-3wFNXtx9Yt40ahlikHbQWh2fUtJZrCNkqgJF1C+fsDo=";
};
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
'';
passthru.updateScript = nix-update-script { };
meta = {
description = "DPI bypass multi platform";
homepage = "https://github.com/bol-van/zapret";
changelog = "https://github.com/bol-van/zapret/releases/tag/v${finalAttrs.version}";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ nishimara ];
mainProgram = "zapret";
# probably gonna work on darwin, but untested
broken = stdenv.hostPlatform.isDarwin;
};
})