NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.48k stars 13.67k forks source link

Nix-shell error for go environment #6538

Closed cswank closed 9 years ago

cswank commented 9 years ago

I'm trying to follow the example from https://www.blogger.com/comment.g?blogID=32054652&postID=2680995835029709788&page=1&token=1424702385950 and ran into an error. It was my first day messing with nix-shell so maybe user error, I'm not sure. Here is the error output:

code.google.com/p/go.text/collate
code.google.com/p/go.text/collate/build
runtime/cgo
go install runtime/cgo: open /nix/store/8pl62z9jizl283big2c012xxvchilzas-go-    1.4.1/share/go/pkg/darwin_amd64/runtime/cgo.a: permission denied
builder for ‘/nix/store/kvd4b7jk8k5qwgmylv2yw3hhy5zgi90f-go1.4-go.text-024681b033be.drv’ failed with exit code 1
cannot build derivation ‘/nix/store/bdnvw22dasac55lvirdxfncdrlxwsxyp-go1.4-go.net-3338d5f109e9.drv’: 1 dependencies couldn't be built
error: build of ‘/nix/store/bdnvw22dasac55lvirdxfncdrlxwsxyp-go1.4-go.net-3338d5f109e9.drv’ failed
/Users/craigswank/.nix-profile/bin/nix-shell: failed to build all dependencies

And my default.nix:

with import <nixpkgs> {}; with goPackages;

buildGoPackage rec {
  name = "gavels";
  buildInputs = [ net osext ];
  goPackagePath = "bitbucket.org/cswank/gavels";
}

I'm doing all this on os x 10.10.1

lucabrunox commented 9 years ago

I think this is a problem because the build is being done in the nix store instead of a temp dir. cc @copumpkin as should be interested in a fix here too. Works fine on linux. Will try to avoid using the $out for all the build stuff, however then I can't test on osx.

cswank commented 9 years ago

Let me know how I can help for testing on os x and I'll be happy to.

copumpkin commented 9 years ago

Yeah, I actually have a fix for this pending on my pure-darwin branch (not master, as I mostly don't use that). As far as I can tell, the issue is that the cgo build is disabled on darwin (it's slightly tricky to enable, but not too hard). Individual go packages that need it then try to be helpful and build cgo for you, but try to install it into the go location in the store, which at that point is read-only. The solution is just to build cgo as part of the go package.

copumpkin commented 9 years ago

I think I've fixed this as of https://github.com/NixOS/nixpkgs/commit/57250fc2cc23a0cf1001698246b0910adc053ecf. @cswank., mind checking to see if you still have trouble?

gridaphobe commented 9 years ago

Closing this for now as nix-shell works just fine with the presented nix expression.