From ebf222a86885a1d46db1b5cce5afcd37d2effbe8 Mon Sep 17 00:00:00 2001 From: Alberto Donato Date: Tue, 29 Oct 2024 15:21:55 +0100 Subject: [PATCH] Pass nix-ld related variables by default in pass_env (fixes #3425) --- docs/changelog/3425.doc.rst | 3 +++ docs/config.rst | 8 ++++++++ src/tox/tox_env/api.py | 8 +++++++- tests/session/cmd/test_show_config.py | 4 +++- 4 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 docs/changelog/3425.doc.rst diff --git a/docs/changelog/3425.doc.rst b/docs/changelog/3425.doc.rst new file mode 100644 index 000000000..35fa8fd5f --- /dev/null +++ b/docs/changelog/3425.doc.rst @@ -0,0 +1,3 @@ +Pass ``NIX_LD`` and ``NIX_LD_LIBRARY_PATH`` variables by default in ``pass_env`` to make generic binaries work under Nix/NixOS. + +- by :user:`albertodonato` diff --git a/docs/config.rst b/docs/config.rst index 81731da67..06e140d5f 100644 --- a/docs/config.rst +++ b/docs/config.rst @@ -534,6 +534,14 @@ Base options - ✅ - ✅ - ✅ + * - NIX_LD* + - ✅ + - ✅ + - ❌ + * - NIX_LD_LIBRARY_PATH + - ✅ + - ✅ + - ❌ diff --git a/src/tox/tox_env/api.py b/src/tox/tox_env/api.py index bdf4a0b0f..ddb6c3c14 100644 --- a/src/tox/tox_env/api.py +++ b/src/tox/tox_env/api.py @@ -236,7 +236,13 @@ def _default_pass_env(self) -> list[str]: # noqa: PLR6301 ], ) else: # pragma: win32 no cover - env.append("TMPDIR") # temporary file location + env.extend( + [ + "TMPDIR", # temporary file location + "NIX_LD", # nix-ld loader + "NIX_LD_LIBRARY_PATH", # nix-ld library path + ], + ) return env def setup(self) -> None: diff --git a/tests/session/cmd/test_show_config.py b/tests/session/cmd/test_show_config.py index 370b91f65..5a2e9b637 100644 --- a/tests/session/cmd/test_show_config.py +++ b/tests/session/cmd/test_show_config.py @@ -126,7 +126,9 @@ def test_pass_env_config_default(tox_project: ToxProjectCreator, stdout_is_atty: + ["CPPFLAGS", "CURL_CA_BUNDLE", "CXX", "FORCE_COLOR", "HOME", "LANG"] + ["LANGUAGE", "LDFLAGS", "LD_LIBRARY_PATH"] + (["MSYSTEM"] if is_win else []) - + ["NETRC", "NO_COLOR"] + + ["NETRC"] + + (["NIX_LD", "NIX_LD_LIBRARY_PATH"] if not is_win else []) + + ["NO_COLOR"] + (["NUMBER_OF_PROCESSORS", "PATHEXT"] if is_win else []) + ["PIP_*", "PKG_CONFIG", "PKG_CONFIG_PATH", "PKG_CONFIG_SYSROOT_DIR"] + (["PROCESSOR_ARCHITECTURE"] if is_win else [])