Connection error when building a custom Go package

Hi nice peeps!

I’m looking for someone who could help me understand why I’m getting some weird behaviour when I try building a Flake with a custom Go package.

I’ve whipped together a very simple Go package to build kubeseal. I know I should use the Go builder in Nixpkgs, but I’m trying to learn how Go builds work under the bonnet with Nix, hence my package uses vanilla mkDerivation to fetch the source and then build kubeseal according to the commands in their Makefile.

Now the Flake works flawlessly on MacOS but it breaks on some Linuxes with a connection error when trying to download kubeseal’s deps declared in go.mod. The funny thing though is that if I get a build environment on Linux with nix develop and then run the genericBuild in there, the package actually builds.

There’s most likely one gazillion things I got wrong, but I’ve got no clue what exactly. If any of you would like to lend a hand, I’ve put together a detailed explanation with a step-by-step procedure to reproduce here:

Thanks alot!

It just occurred to me the “connection error” on downloading Go packages might happen because Nix stops the build from accessing the network? I remember reading something about impure derivations but for the life of me I can’t recall where. If that’s the case, then why does the build work in some instances? Also how does Nix stop programs like go from accessing the network?