Developing go using nix

Developing go using nix-shell was surprisingly easy until I started writing my own package. Since the code is pushed to a private git repository the files generated by go2nix do not work. This might be fixable, but as far as I understand it, I would need to regenerate the nix-files (and commit+push my code into git) after every change to my package. Is there a better way to solve this problem?
At the moment I just use a shell with go installed and develop like I would using any other distribution and manually set the GOPATH. Being able to set the GOPATH to the directory the default.nix file is in would be good enough for development purposes. Since I could change the package and my project at the same time for testing.
Since I am new to go and the nix ecosystem, I do not know what the right way to do this would be or how to set the GOPATH relative to a default.nix file.

How could I setup my development environment using nix-tools to develop my project using go?

1 Like

You can include extra directories using the extraSrcs attribute as found in buildGoPackage: nixpkgs/default.nix at master · NixOS/nixpkgs · GitHub

extraSrcs = [ ../some/directory ];
1 Like

Thanks! That is exactly what I was looking for. The syntax is a little different, but this works for me:

  extraSrcs = [ { goPackagePath = "path/from/src"; src = ../some/directory; } ];