back

by domenkozar·5y ago·view on hn ↗
We've just made Nix support Apple Silicon natively!

I've also been working on tutorials for beginners at https://nix.dev, for example how to set up declarative developer environments.

3 comments
Oh wow, I see it grew a lot since last time I checked.

I got interested in the cross compile section. I normally work on Mac and whenever I need to create a docker container I need to generate binaries for x86_64 linux.

I typically did it by creating another nixpkgs: instance like:

    linux_pkgs = import <nixpkgs> { system = "x86_64-linux"; };
This doesn't exactly do cross compilation and it actually requires linux builder to work (I have one running in docker). There's also option to specify cross compiling, there, but from my experience requires rebuilding pretty much everything from scratch :/

Using pkgCross seems appealing, but I can't find a linux x86_64 target there. The closest I can find is musl64 (which is great, but can't get everything to work with it).

Is it under perhaps another name that I don't recognize, and if it isn't, would be possible to add it, it would greatly help creating docker images on mac.

For non-musl (so GNU libc), it's the awkwardly named gnu64. To test with the classic test package "hello":

     $ nix-build '<nixpkgs>' -A pkgsCross.gnu64.hello
Note that since this is cross-compiled, and not native compilation, you will have to build a lot more.

All "pkgsCross" systems are found in https://github.com/NixOS/nixpkgs/blob/master/lib/systems/exa...

Great! Thank you for that :)
I realize that the current naming is confusing, so while writing a tutorial I opened https://github.com/NixOS/nixpkgs/issues/126949 that hopefully gets us to a naming scheme that's more consistent with the triplets in cross compilation world.

As for the binaries, you need to compile them once and then you can use http://cachix.org/ for free to cache them.

Thanks, that was a question in my mind. Brew does a fairly good job on M1 Macs by maintaining two environments, one M1 native, and one using Rosetta.
is the `--darwin-use-unencrypted-nix-store-volume` switch still necessary when installing? this is just my personal opinion of course, but i think this should be somehow removed (i understand that on a modern mac computer things will still be safe (probably?), but seeing this flag in the install command is just bad for a first-time user)
That's going to be improved once Nix 2.4 comes out.

Another few weeks to get all installer fixes out.