opensnitch: fix daemon cant find iptables in PATH

This commit is contained in:
Jonas Heinrich 2021-12-10 10:46:43 +01:00
parent ce5d933f41
commit a05790a5bf

View File

@ -7,6 +7,7 @@
, lib
, coreutils
, iptables
, makeWrapper
}:
buildGoModule rec {
@ -32,21 +33,25 @@ buildGoModule rec {
modRoot = "daemon";
vendorSha256 = "sha256-LMwQBFkHg1sWIUITLOX2FZi5QUfOivvrkcl9ELO3Trk=";
nativeBuildInputs = [ pkg-config makeWrapper ];
buildInputs = [ libnetfilter_queue libnfnetlink ];
postBuild = ''
mv $GOPATH/bin/daemon $GOPATH/bin/opensnitchd
mkdir -p $out/lib/systemd/system
substitute opensnitchd.service $out/lib/systemd/system/opensnitchd.service \
--replace "/usr/local/bin/opensnitchd" "$out/bin/opensnitchd" \
--replace "/usr/local/bin/opensnitchd" "${out}/bin/opensnitchd" \
--replace "/etc/opensnitchd/rules" "/var/lib/opensnitch/rules" \
--replace "/bin/mkdir" "${coreutils}/bin/mkdir"
sed -i '/\[Service\]/a Environment=PATH=${iptables}/bin' $out/lib/systemd/system/opensnitchd.service
'';
vendorSha256 = "sha256-LMwQBFkHg1sWIUITLOX2FZi5QUfOivvrkcl9ELO3Trk=";
nativeBuildInputs = [ pkg-config ];
buildInputs = [ libnetfilter_queue libnfnetlink ];
postInstall = ''
wrapProgram $out/bin/opensnitchd \
--prefix PATH : ${lib.makeBinPath [ iptables ]}
'';
meta = with lib; {
description = "An application firewall";