Hello *,
I need some help for setting up a proper cross compile shell for aarch64 to compile a go statically linked binary using musl
with race detector on.
Example application:
package main
import "fmt"
func main() {
fmt.Println("vim-go")
}
Current shell.nix:
ith import <nixpkgs> {
crossSystem = {
config = "aarch64-unknown-linux-gnu";
};
};
mkShell {
nativeBuildInputs = [ musl ];
buildInputs = [ go ];
shellHook = ''
alias build='CC=musl-gcc GOARCH=arm64 CGO_ENABLED=1 go build -ldflags="-linkmode external -extldflags=-static" -race -o helloworld'
'';
}
When running the shell on a NixOS system (with go globally installed) everything works fine, but running the shell with --pure to test if it would work in a docker nix container, I get the error message: go command is not found.
Can you give me a hint how to setup a proper cross compile shell to compile a statically linked go binary for aarch64 on a x86_64 system?
Many thanks,
qitta