lix/src/libstore
Matthew Bauer f69820417f Set kern.curproc_arch_affinity=0 to escape Rosetta
By default, once you enter x86_64 Rosetta 2, macOS will try to run
everything in x86_64. So an x86_64 Nix will still try to use x86_64
even when system = aarch64-darwin. To avoid this we can set
kern.curproc_arch_affinity sysctl. With kern.curproc_arch_affinity=0,
we ignore this preference.

This is based on how
https://opensource.apple.com/source/system_cmds/system_cmds-880.40.5/arch.tproj/arch.c.auto.html
works. Completely undocumented, but seems to work!

Note, you can verify this works with this impure Nix expression:

```
  {
    a = derivation {
      name = "a";
      system = "aarch64-darwin";
      builder = "/bin/sh";
      args = [ "-e" (builtins.toFile "builder" ''
        [ "$(/usr/bin/arch)" = arm64 ]
        [ "$(/usr/bin/arch -arch x86_64 /bin/sh -c /usr/bin/arch)" = i386 ]
        [ "$(/usr/bin/arch -arch arm64 /bin/sh -c /usr/bin/arch)" = arm64 ]
        /usr/bin/touch $out
      '') ];
    };

    b = derivation {
      name = "b";
      system = "x86_64-darwin";
      builder = "/bin/sh";
      args = [ "-e" (builtins.toFile "builder" ''
        [ "$(/usr/bin/arch)" = i386 ]
        [ "$(/usr/bin/arch -arch x86_64 /bin/sh -c /usr/bin/arch)" = i386 ]
        [ "$(/usr/bin/arch -arch arm64 /bin/sh -c /usr/bin/arch)" = arm64 ]
        /usr/bin/touch $out
      '') ];
    };
  }
```
2021-01-11 22:40:21 -06:00
..
build Set kern.curproc_arch_affinity=0 to escape Rosetta 2021-01-11 22:40:21 -06:00
builtins
binary-cache-store.cc
binary-cache-store.hh Overhaul store subclassing 2020-12-20 15:47:14 +00:00
builtins.hh
ca-specific-schema.sql
content-address.cc
content-address.hh
crypto.cc Make sodium a required dependency 2021-01-06 17:56:53 +01:00
crypto.hh crypto.cc: API cleanup and add generate() / to_string() methods 2021-01-06 17:04:46 +01:00
daemon.cc
daemon.hh
derivations.cc
derivations.hh
dummy-store.cc Overhaul store subclassing 2020-12-20 15:47:14 +00:00
export-import.cc
filetransfer.cc
filetransfer.hh Add 'nix store prefetch-{file,tarball}' 2021-01-07 21:51:46 +01:00
fs-accessor.hh
gc.cc
globals.cc string2Int(): Return std::optional 2021-01-08 12:22:21 +01:00
globals.hh Merge pull request #4310 from matthewbauer/rosetta2-extra-platforms 2021-01-06 11:31:13 +01:00
http-binary-cache-store.cc Overhaul store subclassing 2020-12-20 15:47:14 +00:00
legacy-ssh-store.cc Overhaul store subclassing 2020-12-20 15:47:14 +00:00
local-binary-cache-store.cc Overhaul store subclassing 2020-12-20 15:47:14 +00:00
local-fs-store.cc
local-fs-store.hh Overhaul store subclassing 2020-12-20 15:47:14 +00:00
local-store.cc string2Int(): Return std::optional 2021-01-08 12:22:21 +01:00
local-store.hh Fix deadlock in LocalStore::addSignatures() 2021-01-05 11:47:29 +01:00
local.mk
lock.cc
lock.hh
machines.cc
machines.hh
misc.cc
names.cc string2Int(): Return std::optional 2021-01-08 12:22:21 +01:00
names.hh
nar-accessor.cc
nar-accessor.hh
nar-info-disk-cache.cc
nar-info-disk-cache.hh
nar-info.cc string2Int(): Return std::optional 2021-01-08 12:22:21 +01:00
nar-info.hh
nix-store.pc.in
optimise-store.cc
parsed-derivations.cc
parsed-derivations.hh
path-info.hh
path.cc
path.hh
pathlocks.cc
pathlocks.hh
profiles.cc string2Int(): Return std::optional 2021-01-08 12:22:21 +01:00
profiles.hh
realisation.cc
realisation.hh
references.cc scanForReferences: Remove misleading comment 2020-12-28 17:21:19 +01:00
references.hh
remote-fs-accessor.cc
remote-fs-accessor.hh
remote-store.cc Overhaul store subclassing 2020-12-20 15:47:14 +00:00
remote-store.hh Overhaul store subclassing 2020-12-20 15:47:14 +00:00
s3-binary-cache-store.cc Overhaul store subclassing 2020-12-20 15:47:14 +00:00
s3-binary-cache-store.hh Overhaul store subclassing 2020-12-20 15:47:14 +00:00
s3.hh
sandbox-defaults.sb
sandbox-minimal.sb
sandbox-network.sb
schema.sql
serve-protocol.hh
sqlite.cc
sqlite.hh
ssh-store.cc Overhaul store subclassing 2020-12-20 15:47:14 +00:00
ssh.cc
ssh.hh
store-api.cc string2Int(): Return std::optional 2021-01-08 12:22:21 +01:00
store-api.hh Overhaul store subclassing 2020-12-20 15:47:14 +00:00
uds-remote-store.cc Overhaul store subclassing 2020-12-20 15:47:14 +00:00
uds-remote-store.hh Overhaul store subclassing 2020-12-20 15:47:14 +00:00
worker-protocol.hh