Debugging a buildgopackage build

I enter with a nix-shell

and the perform the steps by hand.


unpacking source archive /nix/store/5a9q9fnsjswl5kwrsv6ascfsmyhgxwzl-source
source root is source


no configure script, doing nothing

so, I took a look at the source for buildgopackage

and this piece of code

   configurePhase = args.configurePhase or ''
      runHook preConfigure
      # Extract the source
      cd "$NIX_BUILD_TOP"
      mkdir -p "go/src/$(dirname "$goPackagePath")"
      mv "$sourceRoot" "go/src/$goPackagePath"

this is in the current enviroment.

set | grep configurePhase in the nix-shell

configurePhase=$'runHook preConfigure\n\n# Extract the source\ncd "$NIX_BUILD_TOP"\nmkdir -p
"go/src/$(dirname "$goPackagePath")"\nmv "$sourceRoot" "go/src/$goPackagePath"\n\nexport GOPA
TH=$NIX_BUILD_TOP/go:$GOPATH\nexport GOCACHE=$TMPDIR/go-cache\n\nrunHook postConfigure\n'
configurePhase ()

so, why is this code not being run?

I’ve also tried


but still that script doesn’t execute, and the source is not moved.

So what going on here? is the fact the buildgomodule can’t be called from nix-shell? is it different to a nix build enviroment? If so , how do you debug and develop a ‘nix builder’ enviroment?

1 Like

This stumped me too; I’ve found a more reliable way of getting through the build in an interactive shell is to run genericBuild inside the nix shell, instead of manually running each phase.

Also, if you get the error:

unpacker appears to have produced no directories

it may be because a source folder from a previous run has stuck around; rm -rf source should help get past that.

1 Like