nixpkgs/pkgs/tools/networking/opensnitch/daemon.nix

89 lines
2.0 KiB
Nix
Raw Normal View History

{ buildGoModule
, fetchFromGitHub
, fetchpatch
, protobuf
, go-protobuf
, pkg-config
, libnetfilter_queue
, libnfnetlink
, lib
2021-09-13 18:47:32 +00:00
, coreutils
, iptables
, makeWrapper
2022-02-04 11:07:14 +00:00
, protoc-gen-go-grpc
2023-03-11 11:11:26 +00:00
, testers
, opensnitch
2023-08-08 20:00:52 +00:00
, nixosTests
}:
buildGoModule rec {
pname = "opensnitch";
2023-08-20 20:22:44 +00:00
version = "1.6.3";
src = fetchFromGitHub {
owner = "evilsocket";
repo = "opensnitch";
rev = "v${version}";
2023-08-20 20:22:44 +00:00
hash = "sha256-C8Uuz2FC7Zu07ZmFpp+ejpNxkyC3/mM9J2dc5FUKx64=";
};
modRoot = "daemon";
2023-07-31 16:18:09 +00:00
buildInputs = [
libnetfilter_queue
libnfnetlink
];
2023-07-31 16:18:09 +00:00
nativeBuildInputs = [
pkg-config
protobuf
go-protobuf
makeWrapper
protoc-gen-go-grpc
];
vendorHash = "sha256-bUzGWpQxeXzvkzQ7G53ljQJq6wwqiXqbi6bgeFlNvvM=";
preBuild = ''
2022-11-19 18:08:52 +00:00
# Fix inconsistent vendoring build error
# https://github.com/evilsocket/opensnitch/issues/770
cp ${./go.mod} go.mod
cp ${./go.sum} go.sum
make -C ../proto ../daemon/ui/protocol/ui.pb.go
'';
postBuild = ''
mv $GOPATH/bin/daemon $GOPATH/bin/opensnitchd
mkdir -p $out/etc/opensnitchd $out/lib/systemd/system
cp system-fw.json $out/etc/opensnitchd/
substitute default-config.json $out/etc/opensnitchd/default-config.json \
--replace "/var/log/opensnitchd.log" "/dev/stdout"
2021-09-13 18:47:32 +00:00
substitute opensnitchd.service $out/lib/systemd/system/opensnitchd.service \
--replace "/usr/local/bin/opensnitchd" "$out/bin/opensnitchd" \
2021-09-13 18:47:32 +00:00
--replace "/etc/opensnitchd/rules" "/var/lib/opensnitch/rules" \
--replace "/bin/mkdir" "${coreutils}/bin/mkdir"
'';
postInstall = ''
wrapProgram $out/bin/opensnitchd \
--prefix PATH : ${lib.makeBinPath [ iptables ]}
'';
2023-08-08 20:00:52 +00:00
passthru.tests = {
inherit (nixosTests) opensnitch;
version = testers.testVersion {
package = opensnitch;
command = "opensnitchd -version";
};
2023-03-11 11:11:26 +00:00
};
meta = with lib; {
description = "An application firewall";
homepage = "https://github.com/evilsocket/opensnitch/wiki";
license = licenses.gpl3Only;
maintainers = with maintainers; [ onny ];
platforms = platforms.linux;
};
}