From c60c7c645cff5cc9a735abafc6122c9a042c3df6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ha=CC=88cker?= Date: Tue, 18 Nov 2025 21:53:20 +0100 Subject: [PATCH] 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 f5eb10b52cc8f54e1970176e26d2e6627bd240ca) --- nixos/modules/virtualisation/rosetta.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/virtualisation/rosetta.nix b/nixos/modules/virtualisation/rosetta.nix index 2f1310f95db56..765fa13d1d862 100644 --- a/nixos/modules/virtualisation/rosetta.nix +++ b/nixos/modules/virtualisation/rosetta.nix @@ -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;