So, I followed this guide and I got all the way to successfully building a test suite for an internal project at my company. However, I’m still getting a segfault when realizing a certain derivation:
[rune@nixos:~/code/smithy]$ export PATH=$(nix-build --argstr system "x86_64-linux" -A nix '<nixpkgs>')/bin:$PATH
[rune@nixos:~/code/smithy]$ file $(which nix-store)
/nix/store/1qxf5i4na4a4cdykhxki2wyal82kl0zb-nix-2.11.0/bin/nix-store: symbolic link to nix
[rune@nixos:~/code/smithy]$ file $(which nix)
/nix/store/1qxf5i4na4a4cdykhxki2wyal82kl0zb-nix-2.11.0/bin/nix: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /nix/store/4nlgxhb09sdr51nc9hdm8az5b08vzkgx-glibc-2.35-163/lib/ld-linux-x86-64.so.2, BuildID[sha1]=e85442784c8a16559b4921dcffe9d03d6fc75f14, for GNU/Linux 2.6.32, not stripped
[rune@nixos:~/code/smithy]$ nix-store --realize /nix/store/vgw0nd9kgfs3rbvm20144zidxlc4qsax-setup-hook.drv
this derivation will be built:
/nix/store/vgw0nd9kgfs3rbvm20144zidxlc4qsax-setup-hook.drv
building '/nix/store/vgw0nd9kgfs3rbvm20144zidxlc4qsax-setup-hook.drv'...
error: builder for '/nix/store/vgw0nd9kgfs3rbvm20144zidxlc4qsax-setup-hook.drv' failed due to signal 11 (Segmentation fault)
[rune@nixos:~/code/smithy]$ cat /nix/store/vgw0nd9kgfs3rbvm20144zidxlc4qsax-setup-hook.drv
Derive([("out","/nix/store/j1g3pd657hvmyc25hj3syab4hg03vmyr-setup-hook","","")],[("/nix/store/0zhkga32apid60mm7nh92z2970im5837-bootstrap-tools.drv",["out"]),("/nix/store/8v3lzbyagb72zwidrh7k9ggwpsggy0hs-bootstrap-stage4-stdenv-linux.drv",["out"])],["/nix/store/9krlzvny65gdc8s7kpb6lkx8cd02c25b-default-builder.sh"],"x86_64-linux","/nix/store/p4s4jf7aq6v6z9iazll1aiqwb34aqxq9-bootstrap-tools/bin/bash",["-e","/nix/store/9krlzvny65gdc8s7kpb6lkx8cd02c25b-default-builder.sh"],[("allowSubstitutes",""),("buildCommand","target=$out\nmkdir -p \"$(dirname \"$target\")\"\n\nif [ -e \"$textPath\" ]; then\n mv \"$textPath\" \"$target\"\nelse\n echo -n \"$text\" > \"$target\"\nfi\n\neval \"$checkPhase\"\n\n(test -n \"$executable\" && chmod +x \"$target\") || true\n"),("buildInputs",""),("builder","/nix/store/p4s4jf7aq6v6z9iazll1aiqwb34aqxq9-bootstrap-tools/bin/bash"),("checkPhase",""),("configureFlags",""),("depsBuildBuild",""),("depsBuildBuildPropagated",""),("depsBuildTarget",""),("depsBuildTargetPropagated",""),("depsHostHost",""),("depsHostHostPropagated",""),("depsTargetTarget",""),("depsTargetTargetPropagated",""),("doCheck",""),("doInstallCheck",""),("executable",""),("name","setup-hook"),("nativeBuildInputs",""),("out","/nix/store/j1g3pd657hvmyc25hj3syab4hg03vmyr-setup-hook"),("outputs","out"),("passAsFile","buildCommand text"),("patches",""),("preferLocalBuild","1"),("propagatedBuildInputs",""),("propagatedNativeBuildInputs",""),("stdenv","/nix/store/6p6gmzx72i2p0in3cclz25cjlz3d3m7l-bootstrap-stage4-stdenv-linux"),("strictDeps",""),("system","x86_64-linux"),("text","export GZIP=\"-n\"\n")])
So first I create a shell environment where all calls to Nix executables resolve to an x86_64 executable. This executable will then be executed by Rosetta, given that I’ve followed the above-mentioned guide.
I’m not sure how to debug this further, otherwise I would provide more information.