Last active
June 23, 2020 19:11
-
-
Save lobre/7d9a0613a728668083d89e790e094d1f to your computer and use it in GitHub Desktop.
How to nix-shell for Go projects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example with go modules fetched by | |
# nix and linked to the vendor directory | |
# when entering the shell. | |
with import <nixpkgs> {}; | |
buildGoModule { | |
pname = "example"; | |
version = "0.0.1"; | |
src = ./.; | |
vendorSha256 = lib.fakeSha256; # to change at first build | |
shellHook = '' | |
eval "$configurePhase" | |
''; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Simple example with only go as dependency. | |
# To avoid writing in $HOME/go, we define | |
# the $GOPATH in a temporary location. | |
with import <nixpkgs> {}; | |
mkShell { | |
buildInputs = [ go ]; | |
shellHook = '' | |
export GOCACHE=$TMPDIR/go-cache | |
export GOPATH="$TMPDIR/go" | |
''; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment