Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nix
base: fbfa70dc0235
Choose a base ref
...
head repository: NixOS/nix
compare: 4e9cec79bf53
Choose a head ref
  • 2 commits
  • 1 file changed
  • 2 contributors

Commits on Jan 12, 2021

  1. 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
          '') ];
        };
      }
    ```
    matthewbauer committed Jan 12, 2021
    Copy the full SHA
    f698204 View commit details
    Browse the repository at this point in the history

Commits on Jan 13, 2021

  1. Merge pull request #4444 from matthewbauer/unset-curproc-arch-affinity

    Set kern.curproc_arch_affinity=0 to escape Rosetta
    edolstra committed Jan 13, 2021
    Copy the full SHA
    4e9cec7 View commit details
    Browse the repository at this point in the history