Nix can produce static binaries using "pkgsStatic"
Disclaimer: I have very little experience with Nix, but I'd like to be able to use it to easily produce static binaries for Linux using musl libc. (Currently, I use zig cc instead.)
Based on the (so far excellent) nix.dev docs, it looks like you can build an already-in-nixpkgs program with a command line like the following (for hello, i.e. GNU Hello):
nix-build '<nixpkgs>' --arg crossSystem '{ config = "x86_64-unknown-linux-musl"; }' -A 'pkgsStatic.hello'
Notes:
- Specifying the target platform doesn't currently make a difference, but I suspect it could in the future
- You might want to pin nixpkgs for reproducibility