Effects of using x86_64 Nix on M1 Mac

I have an M1 MacBook Air with Nix 2.3.16, unstable channel. When I first installed Nix, I did everything through an x86_64 terminal, so I got the x86_64 version of Nix. This means that any package I install will use the x86_64 version, not the native aarch64 version. What are the effects of this?

My guess is that I have more packages available to install, but the packages I install are slower. Is that correct?

1 Like

My guess is that I have more packages available to install, but the packages I
install are slower. Is that correct?

I’m not super familiar with how Apple’s emulation layer looks and works, but
that seems right to me. If you’re managing things declaratively, you can always
choose which one you want to use for each package, maybe (?) like the following:

let pkgs_ntv = import nixpkgs { system = "aarch64-darwin"; }; # not sure if these triples are accurate :)
    pkgs_eml = import nixpkgs { system = "x86_64-darwin";  };
in {
  # Do all the package stuff you do here
}
1 Like

Ah, I was just about to ask if that was possible. Cool to see the things you can do with Nix!

You may have to configure extra-platforms in nix.conf to include whatever system is not the native one for your Nix install. But yea, I’d recommend having the aarch64 version of Nix itself installed, defaulting to aarch64 for packages, and using system = "x86_64-darwin"; with nixpkgs to get any packages you need that aren’t available on arm (not many IME).

1 Like

Thank you for the advice!

Is there a way to change the Nix platform in-place, or do I have to reinstall?

You can do it in-place. As for how… I just use nix-darwin to automate that. Otherwise I think all you have to do is use something like sudo nix-env -p /nix/var/nix/profiles/default -f "<nixpkgs>" --argstr system aarch64-drawin -iA nix. Which says “Into the root-owned default profile, install the nix attribute from nixpkgs, using the aarch64-darwin system”. I don’t think you have to update the launch daemon plist… but I use nix-darwin, so I’m not sure.

1 Like