How to install nix on MacOS with m1?

I am struggling to install nix on a mac with m1. I have checked out all the related issues, but I am not sure what to do to install properly as an end-user

These are the issues:

How can I install nix on a M1 mac?

I’ve been looking for information on the same topic.

The conclusion so far is that it’s not supported. See supported platforms in the manual:

Maybe possible to use it as x86_64 with Rosetta though? But that seems hugely inefficient since it presumably forces all installed software to also run as x86_64. Happy to hear counter-arguments though :wink:

There’s nixpkgs support for aarch64-darwin now. The issues is how to get a version of nix which is compatible with aarch64-darwin.

Luckily, the 2.3.13 release of nix also updated the installer script to include a proper fix to the install script. https://releases.nixos.org/nix/nix-2.3.13/install

You should be able to curl -L https://nixos.org/nix/install | sh yourself into nix on M1 now. (not sure if the /nix mount is still an issue, don’t own an M1)

1 Like

The mount issue was ~fixed in master via nix#4289, but the changes haven’t been backported to 2.3.x.

At the time, I didn’t really anticipate how far off the next release from master would be–and other/overlapping unreleased work in master adds some friction to backporting it. (If someone wants to try, I outlined likely steps in https://github.com/NixOS/nix/pull/4289#issuecomment-842797556)

1 Like

you can build nix from sources, create a mountpoint /nix by self.

./configure --prefix=/nix --with-boost=$HOME/.me
✿ file /nix/bin/nix                                                                                      ─╯
/nix/bin/nix: Mach-O 64-bit executable arm64

if package support aarch64-darwin, install successful:

✿ file /nix/store/blcjz4b5fjkxlwx5rpzsgq398gf9lgf1-rustc-1.52.1/bin/rustc                                ─╯
/nix/store/blcjz4b5fjkxlwx5rpzsgq398gf9lgf1-rustc-1.52.1/bin/rustc: Mach-O 64-bit executable arm64

if not support aarch64-darwin:

error: Package ‘ghc-8.10.4’ in /nix/store/m62zfwzwss5bap5ly32w5rmnncypfjd5-nixpkgs/nixpkgs/pkgs/development/compilers/ghc/8.10.4.nix:267 is not supported on ‘aarch64-darwin’, refusing to evaluate.

use export NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1 still not work

error: cannot bootstrap GHC on this platform
(use '--show-trace' to show detailed location information)

i hope nix will can install only support x86_64 package with Rosetta

2 Likes

I can confirm Nix 2.3.15 can be properly installed on aarch64-darwin simply following the manual’s instructions: NixOS - Nix 2.3.16 manual

1 Like

You guys should probably be testing Nix 2.4 release candidate :slight_smile:

1 Like