Enable specific architecture (ie, Zen4) support within a NixOS system

I have a Ryzen 7000 setup, and of course I’d want my system build with binaries which take advantage of the new architecture and instructions (AVX-512) in this case.
NixPKGs architecture.nix defines zenver4 as a supported architecture, along with others.

To be clear, I want nixos-rebuild to automatically get the binaries optimised for my CPU and/or compile if needed.

This would require upstream building those binaries, which it doesn’t, and it would be unreasonable to do so for all architectures under the sun.

To be clear, you will need to compile all of those binaries, and nixpkgs packages aren’t exactly optimized for building the minimum feature set like e.g. gentoo, so this will take a lot of time.

To actually change the setting, you can set nixpkgs.hostPlatform to change gcc.arch and gcc.tune for the deployed configuration. YMMV with actually building successfully.

1 Like