Change:
Describe the bug Running river on nixos unstable results in this error: which is caused by this instruction: It is an , and i'm using AMD FX 6350, which only supports regular AVX It seems that zig basically uses something like by default, which is questionable to say at least. I couldn't find an easy way to fix it, so i will leave this as an issue. All other zig packages are possibly affected too, needs verification. To Reproduce Steps to reproduce the behavior: Expected behavior Doesn't use AVX2, build is reproducible. Notify maintainers Metadata Maintainer information:
What I have to do with it if it's not just river but Zig itself? You can ask zig maintainer (creator itself) about it. I will also ask community and river developers.
This is correct, zig builds for the current host by default. If a cross-compile should be performed, a target triple should be given () for example, assuming glibc/GNU abi is used. This is usually passed by to a build script or via on a normal build command line. The code here only builds for the local machine, so it might not be shared with other machines:
So one person on NixOS discord server suggested one simple solution. To eleminate problems like this, user will build river on own hardware, this will prevent problems like this to happen as pointed above Zig takes everything from host e.g libc, ABI, cpu architecture so building it on user's hardware will use those attrinutes according to their hardware, ABI amd libc. Building river doesn't take more then 20s at least on my old 2 core CPU and I don't think bulding it locally is big problem
This is exactly what the creator of the issue is pointing at as a problem, and the only good solution (at least in the Nix way) is to make all programs compiled with Zig target baseline x86_64 (or ultimately whichever features the Nixpkgs pipeline allows in C/C++ derivations) The idea of packaging with Nix is not just "being able to compile and done" but rather being able to compile deterministically.
Indeed, passing to is the correct solution here, and will produce a binary for baseline x86_64. After the next zig release (planned for ~2 weeks from now) passing will be an even better way of doing this, allowing the target to be entirely detected from the host system and allowing specific cpu features to be enabled/disabled.

Discussion:
<del> { lib, stdenv ,fetchFromGitHub , zig, wayland, pkg-config, scdoc , xwayland, wayland-protocols, wlroots , libxkbcommon, pixman, udev, libevdev, libX11, libGL </del> <ins> { lib , stdenv , fetchFromGitHub , zig , wayland , pkg-config , scdoc , xwayland , wayland-protocols , wlroots , libxkbcommon , pixman , udev , libevdev , libX11 , libGL </ins> }: stdenv.mkDerivation rec {

fetchSubmodules = true; }; <del> buildInputs = [ wayland-protocols wlroots pixman libxkbcommon pixman udev libevdev libX11 libGL </del> <ins> nativeBuildInputs = [ zig wayland xwayland scdoc pkg-config ]; buildInputs = [ wayland-protocols wlroots pixman libxkbcommon pixman udev libevdev libX11 libGL </ins> ]; dontConfigure = true;

preBuild = '' export HOME=$TMPDIR ''; installPhase = '' runHook preInstall <del> zig build -Drelease-safe -Dxwayland -Dman-pages --prefix $out install </del> <ins> zig build -Drelease-safe -Dtarget=${stdenv.hostPlatform.parsed.cpu.name}-native -Dxwayland -Dman-pages --prefix $out install </ins> runHook postInstall ''; <del> nativeBuildInputs = [ zig wayland xwayland scdoc pkg-config ]; # Builder patch install dir into river to get default config # When installFlags is removed, river becomes half broken # see https://github.com/ifreund/river/blob/7ffa2f4b9e7abf7d152134f555373c2b63ccfc1d/river/main.zig#L56 </del> <ins> /* Builder patch install dir into river to get default config When installFlags is removed, river becomes half broken. See https://github.com/ifreund/river/blob/7ffa2f4b9e7abf7d152134f555373c2b63ccfc1d/river/main.zig#L56 */ </ins> installFlags = [ "DESTDIR=$(out)" ]; meta = with lib; {