kamilchm / go2nix

Reproducible builds and development environment for Go
MIT License
94 stars 17 forks source link

go2nix seems overly greedy #24

Closed rushmorem closed 7 years ago

rushmorem commented 7 years ago

Sometimes go2nix requires additional packages beyond those required by go build to actually build. For example, if you are packaging coredns, a go get -d ./ is sufficient to fetch all its dependancies for building their main package. However, running go2nix save requires some other packages before it can successfully compile the Nix expressions.

I ran into this a number of times while packaging for Nix, I ended up creating a script that downloads these extra requirements while go2nix saveing:-

#!/bin/sh

while true; do
    missing_package=$(go2nix save 2>&1 | awk -F'"' '{print $2}')
    [[ -z $missing_package ]] && exit 0
    go get -d -v $missing_package
    echo "Finished downloading $missing_package"
done
kamilchm commented 7 years ago

Thx for reporting this. I plan to write tests for go2nix with few packages (i will look at coredns too) as a examples to address https://github.com/kamilchm/go2nix/issues/21. I'll come back to this next week.

kamilchm commented 7 years ago

I found the problem with coredns - unused imports in https://github.com/miekg/coredns/blob/master/core/coredns.go go get and go build won't go as deep as go2nix into these dependencies but I don't know where is the right place to stop going deeper :/ Go package management in it's glory :(

kamilchm commented 7 years ago

Got it, go2nix doesn't look for packages provided in vendor of dependent packages, eg. k8s.io/kubernetes/vendor in this case. I need to implement test cases from https://www.youtube.com/watch?v=6gdVhHMxNTo and then do it right.

kamilchm commented 7 years ago

Fixed in https://github.com/kamilchm/go2nix/releases/tag/v1.1.1