Skip to content

Instantly share code, notes, and snippets.

@eqyiel
Forked from Profpatsch/build-go-pkg.sh
Created February 19, 2017 17:19
Show Gist options
  • Save eqyiel/103d4485ca4c09eddb9ee3656d45deff to your computer and use it in GitHub Desktop.
Save eqyiel/103d4485ca4c09eddb9ee3656d45deff to your computer and use it in GitHub Desktop.
help with packaging go packages in nix
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p go go2nix
# little script to help with the stupid go packaging
# cd into the dir where you want to have the `default.nix`
# go package name (e.g. github.com/go/is-stupid)
PACKAGE="$1"
# git upstream link
GIT="$2"
# doesn’t fucking work, because go2nix ignores the checked out rev
REV="$3"
ORIGPWD="$PWD"
TMPD=$(mktemp -d)
GOPATH=$TMPD/go
PKGDIR="$GOPATH/src/$PACKAGE"
mkdir -p "$PKGDIR"
git clone "$GIT" "$PKGDIR"
pushd "$PKGDIR"
go get
go2nix save --output="$ORIGPWD/default.nix" --deps-file="$ORIGPWD/deps.nix"
popd
# GO SUCKS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment