NixOS (nixos-anywhere) fails to build in cross-compilation (sops-install-secrets written in go)

I’m trying to use nixos-anywhere to install my configuration on an x86_64-linux server. My computer is aarch64-linux (Asahi Linux). I have the following in my computer’s configuration:

  boot.binfmt.emulatedSystems = [
    "x86_64-linux"
  ];

When it tries to build the system closure, it fails with the following error:

error: builder for '/nix/store/2w3p96zdbsqdrjfpm44krsnr4xb7ahym-sops-install-secrets-0.0.1-go-modules.drv' failed with exit code 2;
       last 25 log lines:
       >  sync/once.go:67
       > net.(*resolverConfig).tryUpdate(0xfcd740, {0xafa63c, 0x10})
       >   net/dnsclient_unix.go:388 +0x59 fp=0xc000440b08 sp=0xc000440a80 pc=0x6a6a19
       > net.getSystemDNSConfig(...)
       >       net/dnsclient_unix.go:368
       > net.(*conf).lookupOrder(0xfb9d00, 0xc000440bf0?, {0xc0002c8090, 0x10})
       >      net/conf.go:275 +0xb8 fp=0xc000440b88 sp=0xc000440b08 pc=0x69fff8
       > net.(*conf).hostLookupOrder(0x0?, 0x0?, {0xc0002c8090?, 0x0?})
       >      net/conf.go:228 +0x85 fp=0xc000440c00 sp=0xc000440b88 pc=0x69fda5
       > net.(*Resolver).lookupIP(0xfcd0e0, {0xc1a460, 0xc0003bc190}, {0xaf1b57, 0x3}, {0xc0002c8090, 0x10})
       >         net/lookup_unix.go:64 +0xa7 fp=0xc000440e58 sp=0xc000440c00 pc=0x6b6147
       > net.(*Resolver).lookupIP-fm({0xc1a460?, 0xc0003bc190?}, {0xaf1b57?, 0x0?}, {0xc0002c8090?, 0x7a8e0a?})
       >        <autogenerated>:1 +0x49 fp=0xc000440ea0 sp=0xc000440e58 pc=0x6ca389
       > net.init.func1({0xc1a460?, 0xc0003bc190?}, 0x0?, {0xaf1b57?, 0x5?}, {0xc0002c8090?, 0x14?})
       >       net/hook.go:21 +0x37 fp=0xc000440ee0 sp=0xc000440ea0 pc=0x69e4b7
       > net.(*Resolver).lookupIPAddr.func1()
       >         net/lookup.go:334 +0x37 fp=0xc000440f38 sp=0xc000440ee0 pc=0x6b57b7
       > internal/singleflight.(*Group).doCall(0xfcd0f0, 0xc0003bc1e0, {0xc0002c80a8, 0x14}, 0x0?)
       >         internal/singleflight/singleflight.go:93 +0x35 fp=0xc000440fa8 sp=0xc000440f38 pc=0x69d5d5
       > internal/singleflight.(*Group).DoChan.gowrap1()
       >    internal/singleflight/singleflight.go:86 +0x30 fp=0xc000440fe0 sp=0xc000440fa8 pc=0x69d570
       > runtime.goexit({})
       >         runtime/asm_amd64.s:1700 +0x1 fp=0xc000440fe8 sp=0xc000440fe0 pc=0x4796e1
       > created by internal/singleflight.(*Group).DoChan in goroutine 41
       >    internal/singleflight/singleflight.go:86 +0x2d2
       For full logs, run 'nix log /nix/store/2w3p96zdbsqdrjfpm44krsnr4xb7ahym-sops-install-secrets-0.0.1-go-modules.drv'.
error: 1 dependencies of derivation '/nix/store/17x4qdbjbp29i87rr2dlv1q5rwvmhslj-sops-install-secrets-0.0.1.drv' failed to build
error: 1 dependencies of derivation '/nix/store/gzfip12hmwrcnf7glqjr16y6rb2wvw06-nixos-system-purity-25.05.20250301.303bd80.drv' failed to build

When getting the full log, the relevant part (in my opinion) is:

[logs of previous phases]
Running phase: buildPhase
@nix { "action": "setPhase", "phase": "buildPhase" }
go: downloading golang.org/x/crypto v0.33.0
go: downloading github.com/ProtonMail/go-crypto v1.1.5
runtime: lfstack.push invalid packing: node=0xfffff5504400 cnt=0x1 packed=0xfffff55044000001 -> node=0xfffffffff5504400
fatal error: lfstack.push

runtime stack:
runtime.throw({0xaf7447?, 0x0?})
        runtime/panic.go:1067 +0x48 fp=0xc000313f08 sp=0xc000313ed8 pc=0x4716a8
runtime.(*lfstack).push(0xfffff54ac058?, 0xc0003841c0?)
[more of stacktrace]

The derivation it’s trying to build comes from here as far as I know.
I found this issue which may be related, but I don’t know enough to judge.

Does anyone know how I could fix this, why it happens or how to get around it?

Thank you in advance for any help.

I remember hitting either this, or similar issues of emulating x86_64-linux on Apple Silicon (something about 16K vs 4K pages). Sadly, I couldn’t find an easy solution and shelved the idea to use NixOS on a Macbook because of that.

1 Like