Commit f5eb10b5 authored by Martin Häcker's avatar Martin Häcker
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.
parent f0a5e10f
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;