Downloading nixpkgs allows you to easily cross-compile Nix packages with
nix build .#pkgsCross.architecture.packageName
Where architecture is the target architecture you are cross-compiling to (like aarch64-multiplatform), and packageName is the package you are building (traceroute in this example).
This will output the package output to ./result which should include your output binary in ./result/bin . This output binary typically dynamically linked, but what if we need to cross-compile AND statically link the output binary? We can use pkgsStatic to achieve this:
nix build .#pkgsCross.aarch64-multiplatform.pkgsStatic.traceroute
We could also write a small flake like static-traceroute.nix as shown below and build it with:
nix build -f ./static-traceroute.nix