Commit c60c7c64 authored by Martin Häcker's avatar Martin Häcker Committed by github-actions[bot]
Browse files

virtualisation/rosetta: Perserve ArgvZero to fix python virtualenv creation

Preserving ArgvZero is supported from MacOS 14 Sonoma forward, which is
the current minimum supported version of nixpkgs. See
https://developer.apple.com/documentation/virtualization/running-intel-binaries-in-linux-vms-with-rosetta#Mount-the-Shared-Directory-and-Register-Rosetta

The necessity of this fix came up with python virtual environments,
because python uses the path of the executable (argv zero) to determine
if it should load a virtual environment or not. In the past this was
overriden with NIX_PYTHONEXECUTABLE, NIX_PYTHONPATH and
NIX_PYTHONPREFIX, but we stopped doing that for the python interpreter
so it works more like a normal python interpreter in nix.

Without those variables, in the rosetta emulated case, python was no
longer able to determine where it was called from, and thus could not
correctly activate virtual environments in that case.

(cherry picked from commit f5eb10b5)
parent 2fecba99
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -76,7 +76,7 @@ in
      mask = ''\xff\xff\xff\xff\xff\xfe\xfe\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'';
      fixBinary = true;
      matchCredentials = true;
      preserveArgvZero = false;
      preserveArgvZero = true;

      # Remove the shell wrapper and call the runtime directly
      wrapInterpreterInShell = false;