Go modules issues

I’m trying to set up a dev environment for aerc, and I started with the derivation in master, which works perfectly, provided I call it with a default.nix like this:

with import <nixpkgs> {}; \
  buildGo112Module = callPackage <nixpkgs/pkgs/development/go-modules/generic> {
   go = buildPackages.go_1_12; }; 
  aerc = callPackage ./aerc.nix { go=go_1_12; buildGoModule=buildGo112Module; }; 
in aerc 

(where aerc.nix is the derivation in master).

I have two problems.


I tried cloning the repository and doing a nix-build with the same setup (except for src=./.;), and I get this:

go build \ -ldflags "-X                                                                                                                                        main.Prefix=/nix/store/yi3xzhbidi22rj6kq9k7hj9vrwdjwnjf-aerc-0.2.1 \ 
  -X main.ShareDir=/nix/store/yi3xzhbidi22rj6kq9k7hj9vrwdjwnjf-aerc-0.2.1/share/aerc \ 
  -X main.Version=0.2.1" \
   -o aerc
go: finding github.com/go-ini/ini v1.44.0 go: finding github.com/emersion/go-imap v1.0.0 
go: finding github.com/martinlindhe/base36 v1.0.0
go: finding github.com/stretchr/testify v1.3.0 go: finding git.sr.ht/~sircmpwn/tcell v0.0.0-20190807054800-3fdb6bc01a50 
go: git.sr.ht/~sircmpwn/tcell@v0.0.0-20190807054800-3fdb6bc01a50: open /nix/store/17a5g4bn7754n9312rvy90wj0jvkvrs6-aerc-0.2.1-go-modules/git.sr.ht/~sircmpwn/tcell/@v/v0.0.0-20190807054800-3fdb6bc01a50.info: no such file or directory
go: finding github.com/zenhack/go.notmuch v0.0.0-20190726231123-3d59f87d986e 
go: github.com/zenhack/go.notmuch@v0.0.0-20190726231123-3d59f87d986e: open /nix/store/17a5g4bn7754n9312rvy90wj0jvkvrs6-aerc-0.2.1-go-modules/github.com/zenhack/go.notmuch/@v/v0.0.0-20190726231123-3d59f87d986e.info: no such file or directory                              

So it seems that go modules from github are being installed normally, but those from different repositories are erroring.
How can I solve that?

Going back to an earlier commit, between the one in the original derivation and master, where the packages were all in github, nix-build runs successfully.


Also, if I do nix-shell and then fetchPhase, configurePhase, in the buildPhase I get:

flags: SHELL=/nix/store/mn4jdnhkz12a6yd6jg6wvb4mqpxf8q1f-bash-interactive-4.4-p23/bin/bash go build \ 
  -ldflags "-X main.Prefix=/usr/local \ 
   -X main.ShareDir=/usr/local/share/aerc \ 
   -X main.Version=0.2.1" \ 
   -o aerc 
go: github.com/emersion/go-maildir@v0.0.0-20190727102040-941194b0ac70: mkdir /nix/store/y1mgms38574a3w6jpm8bpa762j5wn9xg-go-1.12.1/share/go/pkg/mod: read-only file system 
go: github.com/kyoh86/xdg@v1.0.0: mkdir /nix/store/y1mgms38574a3w6jpm8bpa762j5wn9xg-go-1.12.1/share/go/pkg/mod: read-only file system 
go: github.com/smartystreets/goconvey@v0.0.0-20190710185942-9d28bd7c0945: mkdir /nix/store/y1mgms38574a3w6jpm8bpa762j5wn9xg-go-1.12.1/share/go/pkg/mod: read-only file system 
go: github.com/go-ini/ini@v1.44.0: mkdir /nix/store/y1mgms38574a3w6jpm8bpa762j5wn9xg-go-1.12.1/share/go/pkg/mod: read-only file system         

Is this an issue of setting $GOPATH? But why does it work in nix-build and not here?

Could you please reformat the logs of nix-build and nix-shell? Where the domain git.sr.ht is used, It’s almost unviewable unless one scrolls to the right… It’s also not very clear because of this which message came out first.

Wow, sorry, I didn’t notice that copy and paste mess.

I believe it was something like this, but I’m on a different PC now.

Never mind, the first problem was just me not having changed the modSha256.

Still don’t know what to do about the second one, though.

And this fixed the second problem too, but I don’t know why

with import <nixpkgs> {};
  buildGo112Module = callPackage ~/src/nixpkgs/pkgs/development/go-modules/generic {
    go = buildPackages.go_1_12;
  aerc = callPackage ./aerc.nix { go=go_1_12; buildGoModule=buildGo112Module; };
  stdenv.mkDerivation {
  name = "build";
  buildInputs = aerc.buildInputs ++ aerc.nativeBuildInputs ++ [];
        export GOCACHE=$TMPDIR/go-cache
      export GOPATH="$TMPDIR/go"
      mkdir -p "''${GOPATH}/pkg/mod/cache/download"

I fixed the nix-shell problem like this: