From d14eb443838fde37ee33123618d9ee63dac18321 Mon Sep 17 00:00:00 2001 From: Florian Warzecha Date: Sun, 15 Oct 2023 14:51:45 +0200 Subject: [PATCH 1/3] vpn-slice: add iproute2,iptables to propagatedBuildInputs Those executables are needed for correct operation of vpn-slice during runtime. Otherwise the error message "cannot execute /sbin/ip" / "cannot execute /sbin/iptables" occurrs. --- pkgs/tools/networking/vpn-slice/default.nix | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pkgs/tools/networking/vpn-slice/default.nix b/pkgs/tools/networking/vpn-slice/default.nix index 3d883dca5b11..2bcb526b8670 100644 --- a/pkgs/tools/networking/vpn-slice/default.nix +++ b/pkgs/tools/networking/vpn-slice/default.nix @@ -1,4 +1,11 @@ -{ lib, buildPythonApplication, nix-update-script, python3Packages, fetchFromGitHub }: +{ lib +, buildPythonApplication +, nix-update-script +, python3Packages +, fetchFromGitHub +, iproute2 +, iptables +}: buildPythonApplication rec { pname = "vpn-slice"; @@ -11,7 +18,10 @@ buildPythonApplication rec { sha256 = "sha256-T6VULLNRLWO4OcAsuTmhty6H4EhinyxQSg0dfv2DUJs="; }; - propagatedBuildInputs = with python3Packages; [ setproctitle dnspython ]; + propagatedBuildInputs = with python3Packages; [ setproctitle dnspython ] ++ [ + iproute2 + iptables + ]; doCheck = false; From 46e4e8ad839bfe5ef520a66d4e5665a546c5169e Mon Sep 17 00:00:00 2001 From: Florian Warzecha Date: Mon, 16 Oct 2023 17:03:05 +0200 Subject: [PATCH 2/3] vpn-slice: fix propagated dependencies on darwin vpn-slice has different requirements for externally available commands depending on the os: > Supported OSes: > - Linux kernel 3.x+ with iproute2 and iptables utilities (used for all routing setup) > - macOS 10.x with BSD route --- pkgs/tools/networking/vpn-slice/default.nix | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pkgs/tools/networking/vpn-slice/default.nix b/pkgs/tools/networking/vpn-slice/default.nix index 2bcb526b8670..3fcc0787b184 100644 --- a/pkgs/tools/networking/vpn-slice/default.nix +++ b/pkgs/tools/networking/vpn-slice/default.nix @@ -1,10 +1,12 @@ { lib +, stdenv , buildPythonApplication , nix-update-script , python3Packages , fetchFromGitHub , iproute2 , iptables +, unixtools }: buildPythonApplication rec { @@ -18,10 +20,13 @@ buildPythonApplication rec { sha256 = "sha256-T6VULLNRLWO4OcAsuTmhty6H4EhinyxQSg0dfv2DUJs="; }; - propagatedBuildInputs = with python3Packages; [ setproctitle dnspython ] ++ [ - iproute2 - iptables - ]; + propagatedBuildInputs = with python3Packages; [ setproctitle dnspython ] + ++ lib.optionals stdenv.isLinux [ + iproute2 + iptables + ] ++ lib.optionals stdenv.isDarwin [ + unixtools.route + ]; doCheck = false; From 5b831082575b1539bcf05d2e688634fe20334201 Mon Sep 17 00:00:00 2001 From: Florian Warzecha Date: Tue, 17 Oct 2023 19:09:57 +0200 Subject: [PATCH 3/3] vpn-slice: replace propagatedInputs with substituteInPlace Does not rely on python builder specific magic to provide the runtime binaries this way. --- pkgs/tools/networking/vpn-slice/default.nix | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/pkgs/tools/networking/vpn-slice/default.nix b/pkgs/tools/networking/vpn-slice/default.nix index 3fcc0787b184..3fb921bb44b8 100644 --- a/pkgs/tools/networking/vpn-slice/default.nix +++ b/pkgs/tools/networking/vpn-slice/default.nix @@ -20,13 +20,16 @@ buildPythonApplication rec { sha256 = "sha256-T6VULLNRLWO4OcAsuTmhty6H4EhinyxQSg0dfv2DUJs="; }; - propagatedBuildInputs = with python3Packages; [ setproctitle dnspython ] - ++ lib.optionals stdenv.isLinux [ - iproute2 - iptables - ] ++ lib.optionals stdenv.isDarwin [ - unixtools.route - ]; + postPatch = lib.optionalString stdenv.isDarwin '' + substituteInPlace vpn_slice/mac.py \ + --replace "'/sbin/route'" "'${unixtools.route}/bin/route'" + '' + lib.optionalString stdenv.isLinux '' + substituteInPlace vpn_slice/linux.py \ + --replace "'/sbin/ip'" "'${iproute2}/bin/ip'" \ + --replace "'/sbin/iptables'" "'${iptables}/bin/iptables'" + ''; + + propagatedBuildInputs = with python3Packages; [ setproctitle dnspython ]; doCheck = false;