From 96eb5ef156641ffc4c5ff01befe73a3419b346bc Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 13 Oct 2022 11:45:30 -0700 Subject: [PATCH] Improve Rosetta detection Turns out that one of those *.plist files can exist even if Rosetta is not installed. So let's just try to run an x86_64-darwin binary directly. --- src/libstore/globals.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libstore/globals.cc b/src/libstore/globals.cc index d724897bb..c3d5f9b8c 100644 --- a/src/libstore/globals.cc +++ b/src/libstore/globals.cc @@ -154,12 +154,12 @@ StringSet Settings::getDefaultExtraPlatforms() // machines. Note that we can’t force processes from executing // x86_64 in aarch64 environments or vice versa since they can // always exec with their own binary preferences. - if (pathExists("/Library/Apple/System/Library/LaunchDaemons/com.apple.oahd.plist") || - pathExists("/System/Library/LaunchDaemons/com.apple.oahd.plist")) { - if (std::string{SYSTEM} == "x86_64-darwin") - extraPlatforms.insert("aarch64-darwin"); - else if (std::string{SYSTEM} == "aarch64-darwin") + if (std::string{SYSTEM} == "aarch64-darwin") { + if (runProgram(RunOptions {.program = "arch", .args = {"-arch", "x86_64", "/bin/pwd"}, .mergeStderrToStdout = true}).first == 0) { + debug("Rosetta detected"); extraPlatforms.insert("x86_64-darwin"); + } else + debug("Rosetta not detected"); } #endif