Skip to content
This repository has been archived by the owner on Aug 26, 2021. It is now read-only.

glide support? #19

Open
nshalman opened this issue Jun 22, 2016 · 17 comments
Open

glide support? #19

nshalman opened this issue Jun 22, 2016 · 17 comments

Comments

@nshalman
Copy link

I'm currently building the Cerana tools with what is probably a bit of a terrible hack:
https://github.com/cerana/nixpkgs/blob/ceranaos/pkgs/os-specific/linux/cerana/default.nix#L21

We use glide to manage the dependencies, and I'm wondering if go2nix either already supports software doing vendoring with glide, if it's something that might come in the future, or if I should plan to stick with that hack for a while.

Thank you for all of your hard work making working with Go software in Nix as pleasant as possible!

@kamilchm
Copy link
Owner

I'll think about support for godep and glide in July. One thing that needs to be managed somehow are repo checksums for dependencies that other package managers don't provide :/

@rushmorem
Copy link
Contributor

rushmorem commented Aug 12, 2016

@nshalman That hack is not necessary at all. For example, you can do something like the following instead:-

export GOPATH=$(mktemp -d /tmp/cerana.XXXXXX)
mkdir -p $GOPATH/src/github.com/cerana
cd $GOPATH/src/github.com/cerana
git clone https://github.com/cerana/cerana.git
cd cerana
git checkout ea99f44a58faffcbfa9b68d284340c4187f046dd
glide install
go2nix save

At this point, all you need to do is copy the generated default.nix and deps.json (now deps.nix) to your cerena package in the nixpkgs tree and then edit default.nix to include your postBuild hook.

@kamilchm kamilchm modified the milestone: release-1.2 Dec 13, 2016
@sheenobu
Copy link

@rushmorem The deps.nix file becomes empty in your process. go2nix save seems to ignore the 'vendor' folder when determining dependencies.

@rushmorem
Copy link
Contributor

@sheenobu This is a bug in the current version (v1.1.1). @kamilchm I meant to report this earlier but I never got around to doing it. For now I just use v1.1.0.

@kamilchm
Copy link
Owner

kamilchm commented Dec 29, 2016

I don't think its a bug. Current Go vendoring scheme implies that every dependency found in vendor makes the same dependency in GOPATH obsolete and go2nix doesn't need to add it as an external dependency because it won't be used in the build process.
But there are cases of managing vendor dir with tools like glide or govendor.
The best solution I can think of is to add --manage-vendor flag and add vendor deps to nix when it's set.

@kamilchm
Copy link
Owner

I could also add glide support explicitly but it looks like it's better to align go2nix with https://github.com/sdboyer/gps in the long term.

@rushmorem
Copy link
Contributor

Current Go vendoring scheme implies that every dependency found in vendor makes the same dependency in GOPATH obsolete and go2nix doesn't need to add it as an external dependency because it won't be used in the build process.

This assumes that the vendor directory is committed into the source repo which is not always the case. In my own repos, I always ignore the vendor dir so my deps.nix is always empty when using v1.1.1. I noticed this with other external repos as well. I think another option is to check if the vendor dir is being ignored by the scm's ignore file.

@domenkozar
Copy link

I'm trying to package https://github.com/DataDog/gohai with this process and I'm also getting an empty file. Is there a workaround atm?

@kamilchm
Copy link
Owner

Glide was changed a lot since this issue was created :/ I want to wait until golang/dep#380 and implement new go2nix with dep support only.
Quick & dirty workaround:

glide install
rm -rf vendor
cat glide.lock | grep -o "name:.*" | awk '{ pkg = $2; gsub(/\//, "-"); printf("mkdir -p $GOPATH/src/%s && rsync -aP ~/.glide/cache/src/https-%s/ $GOPATH/src/%s/\n", pkg, $2, pkg); }' | xargs -I {} sh -c '{}'
go2nix save

@rushmorem
Copy link
Contributor

@kamilchm

cat glide.lock | grep -o "name:.*" | awk '{ pkg = $2; gsub(///, "-"); printf("mkdir -p $GOPATH/src/%s && rsync -aP ~/.glide/cache/src/https-%s/ $GOPATH/src/%s/\n", pkg, $2, pkg); }' | xargs -I {} sh -c '{}'

When I try that in my private repo I'm getting xargs: command too long.

@rushmorem
Copy link
Contributor

rushmorem commented May 5, 2017

It's an internal company project that's not available publicly. If I remove the last part to get the input being piped to xargs I get:-

mkdir -p $GOPATH/src/github.com/gin-gonic/gin && rsync -aP ~/.glide/cache/src/https-github.aaakk.us.kg-gin-gonic-gin/ $GOPATH/src/github.com/gin-gonic/gin/
mkdir -p $GOPATH/src/github.com/go-gremlin/gremlin && rsync -aP ~/.glide/cache/src/https-github.aaakk.us.kg-go-gremlin-gremlin/ $GOPATH/src/github.com/go-gremlin/gremlin/
mkdir -p $GOPATH/src/github.com/golang/protobuf && rsync -aP ~/.glide/cache/src/https-github.aaakk.us.kg-golang-protobuf/ $GOPATH/src/github.com/golang/protobuf/
mkdir -p $GOPATH/src/github.com/gorilla/websocket && rsync -aP ~/.glide/cache/src/https-github.aaakk.us.kg-gorilla-websocket/ $GOPATH/src/github.com/gorilla/websocket/
mkdir -p $GOPATH/src/github.com/kr/beanstalk && rsync -aP ~/.glide/cache/src/https-github.aaakk.us.kg-kr-beanstalk/ $GOPATH/src/github.com/kr/beanstalk/
mkdir -p $GOPATH/src/github.com/manucorporat/sse && rsync -aP ~/.glide/cache/src/https-github.aaakk.us.kg-manucorporat-sse/ $GOPATH/src/github.com/manucorporat/sse/
mkdir -p $GOPATH/src/github.com/miekg/dns && rsync -aP ~/.glide/cache/src/https-github.aaakk.us.kg-miekg-dns/ $GOPATH/src/github.com/miekg/dns/
mkdir -p $GOPATH/src/github.com/satori/go.uuid && rsync -aP ~/.glide/cache/src/https-github.aaakk.us.kg-satori-go.uuid/ $GOPATH/src/github.com/satori/go.uuid/
mkdir -p $GOPATH/src/golang.org/x/net && rsync -aP ~/.glide/cache/src/https-golang.org-x-net/ $GOPATH/src/golang.org/x/net/
mkdir -p $GOPATH/src/gopkg.in/go-playground/validator.v8 && rsync -aP ~/.glide/cache/src/https-gopkg.in-go-playground-validator.v8/ $GOPATH/src/gopkg.in/go-playground/validator.v8/
mkdir -p $GOPATH/src/gopkg.in/yaml.v2 && rsync -aP ~/.glide/cache/src/https-gopkg.in-yaml.v2/ $GOPATH/src/gopkg.in/yaml.v2/

Don't worry too much about it though. I just wanted to bring this to your attention so you know this doesn't always work out but I'm not really trying to make it work for this particular project. It's an old project I'm already rewriting in another language.

@kamilchm
Copy link
Owner

kamilchm commented May 5, 2017

It must be something with -I {} in xargs.
I follow dep and there's a good news golang/dep#500 - one more step to unify go dependency management.
I will probably drop all issues with current go2nix and start working on translating gopkg.lock into nix derivation.

@rushmorem
Copy link
Contributor

I follow dep and there's a good news golang/dep#500 - one more step to unify go dependency management.

Awesome.

@copumpkin
Copy link

Another vote for this, since a package I use uses glide for dependency management and I'd like to put it in nixpkgs.

@CMCDragonkai
Copy link

What about other package managers like dep or gx? How does go2nix deal with all of these?

@kamilchm
Copy link
Owner

There's a new thing for dep -> https://github.com/nixcloud/dep2nix. You could try that.
As for other package tools/managers, I think that we should stick with dep to generate nix derivations and use or write new importers for it https://github.com/golang/dep/tree/master/internal/importers

@CMCDragonkai
Copy link

There's also discussion about the new go package management on HN as well. What if that becomes official?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants