kamilchm / go2nix

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

Add support for sub-packages #22

Open rushmorem opened 8 years ago

rushmorem commented 8 years ago

If you have a number of sub-packages that share a common repo, it can be very inconvenient to have to run go2nix save in each package separately.

qknight commented 6 years ago

i've hacked together this script and it is a helper in getting the deps together.

using https://github.com/nixcloud/nix-beautify we can now generate nice and unique deps.nix files:

uniqueDeps.sh

#!/usr/bin/env bash

#https://groups.google.com/forum/#!topic/golang-nuts/611QEJqkDKw
#deps=$(go list -f {{.Deps}})
pushd nixcloud.io/auth-server/
deps=$(go list -f '{{join .Deps "\n"}}' |  xargs go list -f '{{if not .Standard}}{{.ImportPath}}{{end}} ' | sort | uniq)
popd

rm -Rf mydeps
mkdir mydeps

for i in $deps; do
  echo $i
  pushd $i
  go2nix save
  popd
  d=$(echo $i | base64)
  cp $i/deps.nix mydeps/$d.nix
done

pushd mydeps
cat * | grep -v '\[' | grep -v '\]' | grep -v "This file was generated" > deps.nix
echo '[' > deps.nix_
cat deps.nix >> deps.nix_
echo ']' >> deps.nix_
mv deps.nix_ deps.nix
nix-instantiate --eval --strict -E 'let pkgs=import <nixpkgs>{}; in pkgs.lib.unique (import ./deps.nix)' | sed -e 's/};/};\n/g' | sed -e 's/} /}\n/g' | sed -e 's/{/{\n/g' | sed -e 's/; /;\n/g' > deps.nix_
popd

cat deps.nix_ | nix-beautify > deps.nix
qknight commented 6 years ago

@kamilchm might interest you, i've hacked https://github.com/nixcloud/dep2nix together

kamilchm commented 6 years ago

I'm less in Go now and I couldn't find time to complete my dep branch. I'm glad someone did it 👍