Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Golang] Link src root w/package path prefix in nix-shell #46553

Closed
wants to merge 5 commits into from

Conversation

ramirez7
Copy link
Contributor

@ramirez7 ramirez7 commented Sep 11, 2018

Motivation for this change

A buildGoPackage derivation does not have its project root
linked correctly in $GOPATH within nix-shell. This causes
go build/run/test to all fail. $PWD is on $GOPATH, but the
code there is not nested under a directory matching the
import path, so imports fail.

Things done

Modify buildGoPackage's shellHook to ln project root under the package path of directories. I used $PWD for project root, but I'm unsure if there's a better way to do that.

  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Fits CONTRIBUTING.md.

A buildGoPackage derivation does not have its project root
linked correctly in $GOPATH within nix-shell. This causes
go build/run/test to all fail. $PWD is on $GOPATH, but the
code there is not nested under a directory matching the
import path, so imports fail.
@ramirez7
Copy link
Contributor Author

@matthewbauer @kamilchm Could this get merged? It's the only thing blocking me from using nixpkgs HEAD right now. I pinged you two since you interacted w/my last Go PR :)

@ramirez7
Copy link
Contributor Author

ramirez7 commented Mar 14, 2019

@kamilchm I think I have to change this slightly. Instead of $PWD I think we should link src in case we're nix-shellinfo elsewhere. Nevermind :)

@ramirez7
Copy link
Contributor Author

@kamilchm This is good to merge 👍

@ramirez7
Copy link
Contributor Author

ramirez7 commented Jul 3, 2019

This PR has drifted a lot (it got moved to go-modules instead of go-packages somehow).

Closing in favor of the up-to-date #64264

@ramirez7 ramirez7 closed this Jul 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants