From ce8e9df4d7f98c6f35d38f6a6995148e1fcbe54a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Forsman?= Date: Thu, 31 Mar 2022 13:16:20 +0200 Subject: [PATCH] arcanist: add python3 to fix 'arc anoid' Patch out the requirement from 'arc' that it needs 'python3' in $PATH at runtime, because once built the python script will have a fixed absolute path shebang to python3. (The check makes sense outside of Nix though.) Not injecting python3 in PATH prevents leaking python3 into the environment in which arc runs linters etc. --- .../tools/misc/arcanist/default.nix | 5 +++- .../dont-require-python3-in-path.patch | 26 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 pkgs/development/tools/misc/arcanist/dont-require-python3-in-path.patch diff --git a/pkgs/development/tools/misc/arcanist/default.nix b/pkgs/development/tools/misc/arcanist/default.nix index 9540f1e0a6c8..0fa34c7eefe8 100644 --- a/pkgs/development/tools/misc/arcanist/default.nix +++ b/pkgs/development/tools/misc/arcanist/default.nix @@ -6,6 +6,7 @@ , lib, stdenv , installShellFiles , which +, python3 }: # Make a custom wrapper. If `wrapProgram` is used, arcanist thinks .arc-wrapped is being @@ -33,7 +34,9 @@ stdenv.mkDerivation { sha256 = "0jiv4aj4m5750dqw9r8hizjkwiyxk4cg4grkr63sllsa2dpiibxw"; }; - buildInputs = [ php ]; + patches = [ ./dont-require-python3-in-path.patch ]; + + buildInputs = [ php python3 ]; nativeBuildInputs = [ bison flex installShellFiles ]; diff --git a/pkgs/development/tools/misc/arcanist/dont-require-python3-in-path.patch b/pkgs/development/tools/misc/arcanist/dont-require-python3-in-path.patch new file mode 100644 index 000000000000..5c127491bb84 --- /dev/null +++ b/pkgs/development/tools/misc/arcanist/dont-require-python3-in-path.patch @@ -0,0 +1,26 @@ +Don't require python3 in PATH + +Once packaged, the arcanoid.py script has an absolute path shebang to +python3, so there is no need to also require python3 in PATH. + +This prevents leaking in a python3 in PATH in the environment which arc +runs linters etc. + +Author: bjorn.forsman@gmail.com +diff -uNr arcanist.orig/src/workflow/ArcanistAnoidWorkflow.php arcanist.new/src/workflow/ArcanistAnoidWorkflow.php +--- arcanist.orig/src/workflow/ArcanistAnoidWorkflow.php 2022-03-31 13:23:30.865095192 +0200 ++++ arcanist.new/src/workflow/ArcanistAnoidWorkflow.php 2022-04-01 12:19:15.644159639 +0200 +@@ -24,13 +24,6 @@ + } + + public function runWorkflow() { +- if (!Filesystem::binaryExists('python3')) { +- throw new PhutilArgumentUsageException( +- pht( +- 'The "arc anoid" workflow requires "python3" to be available '. +- 'in your $PATH.')); +- } +- + $support_dir = phutil_get_library_root('arcanist'); + $support_dir = dirname($support_dir); + $support_dir = $support_dir.'/support/';