Skip to content

Instantly share code, notes, and snippets.

@Profpatsch
Created December 5, 2016 12:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Profpatsch/41e92f2ae829ad5753e366906e583ddc to your computer and use it in GitHub Desktop.
Save Profpatsch/41e92f2ae829ad5753e366906e583ddc 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