4 ms·
How does nix deal with different CPU architectures? If I have some developers using an ARM based macbook, and some devs on an x86_64 based machine, is it easy
by WatchDog 3y ago
How does nix deal with different CPU architectures?
If I have some developers using an ARM based macbook, and some devs on an x86_64 based machine, is it easy to support both without much maintenance?
- lillecarl 3y agoThe Nix binary cache does x86_64-linux, aarch64-linux, x86_64-darwin, aarch64-darwin and maybe others. Every single package is different, but built from the same source. You won't be sharing binary cache even for python or other interpreted things since they depend on "stdenv" which contains bash. But in practice it's really easy. Though if you're all into robustness you should probably test on the same arch you deploy to eventually.
- takeda 3y agoOne way of thinking about Nix is like A Makefile on steroids. It will build what is needed for the right platform. It is also smart enough that you can add cache server and when it needs something that already is in the cache[1] it will download and use binary package seamlessly. Those packages are built from the same sources with same (or almost the same) configuration options and for all intents and purposes should be nearly identical. So while you use your devenv, it will download and use the right packages for your architecture, and if something is missing on the cache server it will build it locally. Now as ARM Mac's are as popular as the intel ones, people are making sure that the packages build on both. [1] nix generates a hash which is based on the package source code, compile options, architecture etc. and uses that for the lookup.
- pxc 3y ago> If I have some developers using an ARM based macbook, and some devs on an x86_64 based machine, is it easy to support both without much maintenance? Yes. I maintain a small collection of Nix packages at my job (some of which come straight from upstream, some of which I've written in-house and are out-of-tree) for use in development and CI environments. We currently support both Intel and Apple Silicon Macs as well as x86_64 Linux environments. There are a couple of small OS-specific tweaks in one or two packages (which we inherit from those packages, which ship OS-specific scripts). There is no architecture-specific code in the repo; I literally never have to think about it. Target platforms are all tested in CI. Deployment targets (users, CI runners) on all supported platforms get the exact same versions of everything, in binary form appropriate to their architecture.