Golang - specify goroot for my ide goland

How can I specify my goroot path for go sdk for my ide?


At the moment the following path is GOROOT="/nix/store/k8ddnfybpv1ag4z7k5b17i7naalljy9a-go-1.4-bootstrap-20161024/share/go" and of course with the wrong permissions. Is it a good idea to change the permissions there for my user?

How is the Nixos way?

Thx Bavra

How are the permissions wrong?

In the nix store everything is world readable, but writable for no one.

Nothing should write to the GOROOT anyway.

And how can I now set the /etc/environment variables under nixos They do not exist, just like the .profile or .bashrc. Should I create them myself or are they somewhere else?

I am just trying to create my own variables:


without losing them at every start.

Depending on how you installed go it should be in your profile, it usually knows well enough about where it’s GOROOT is.

Try go env GOROOT.

Thank you very much, my goroot, gopath, gobin are here:


so far, so good. But my IDE Goland also wants to have a GOROOT, see screenshot. So the path “/nix/store/k8ddnfybpv1ag4z7k5b17i7naalljy9a-go-1.4-bootstrap-20161024/share/go” is of no use. Even with the path “/run/current-system/sw/share/go” I don’t reach the goal.

What is in NIXOS the equivalent directory to “/usr/local/share/go” or “/usr/local/bin?”
And where can I set the env variables for my user or globally. In the “configuration.nix”?

I have found that, am I right there?

 config.environment.variables =

Thx very much!

Whatever the go you want to use prints as it’s go env GOROOT.

I guess the disadvantage here is that every time you do a nixos-rebuild this will change, no? And if you forget to update it, you’re pointing to an old version of go …