Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

buildGoPackage's fetcher don't remove submodules #98848

Closed
yihuang opened this issue Sep 26, 2020 · 2 comments
Closed

buildGoPackage's fetcher don't remove submodules #98848

yihuang opened this issue Sep 26, 2020 · 2 comments
Labels
0.kind: packaging request 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: golang

Comments

@yihuang
Copy link
Contributor

yihuang commented Sep 26, 2020

ref: https://github.com/golang/go/blob/master/src/cmd/vendor/golang.org/x/mod/zip/zip.go#L212
go get will remove submodules(subdirectories with go.mod in it) after fetch repo, but the fetcher in buildGoPackage simply use fetchgit clone the whole repo.
This has some potential bad effect, also might be an issue when we want to support different versions of submodules from same repo in tools like vgo2nix.
If we simply add postFetch hook to fetchgit to remove directories in repo, the sha256 would not match, an option would be create a wrapper derivation to copy/link the sources (what's the idiomatic way to do this in nix?).

$ GOPATH=`pwd` go get -d github.com/yihuang/test-golang-module-major-version/v2@master
$ ls -1 ./pkg/mod/github.com/yihuang/test-golang-module-major-version/v2@v2.0.2-0.20200924181748-4a13e4bfd5a9
a.go
go.mod
$ git clone https://github.com/yihuang/test-golang-module-major-version.git
$ ls -1 test-golang-module-major-version
a.go
go.mod
sub
yihuang added a commit to yihuang/nixpkgs that referenced this issue Sep 27, 2020
set `moduleDir` to enable new behaviour, empty string for root module,
so it's backward compatible. When new behaviour enabled, it will:
- omit submodules (subdirectoires which contains go.mod)
- able to fetch specific submodules in a repo

make shellHook work with multiple major versions

Fix NixOS#98848
Fix NixOS#98604
@stale
Copy link

stale bot commented Mar 26, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Mar 26, 2021
@yihuang
Copy link
Contributor Author

yihuang commented Mar 26, 2021

since vgo2nix is superseded by gomod2nix, closing.

@yihuang yihuang closed this as completed Mar 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: packaging request 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: golang
Projects
None yet
Development

No branches or pull requests

2 participants