ability to specifiy a go language version
CONTEXT
Other languages have the ability to specify a specific version of the language to be used in the devenv.nix file.
Example: languages.python.version = "3.11.3"; works great, love it.
Go does not, and it is frustrating (and not best practice according to support channel in discord) to try and pin specific commit hashes of older versions.
Go has the package language option (which is great that its there) here: https://devenv.sh/reference/options/#languagesgopackage
but no examples of what a properly formatted input looks like. seems to be happy with pkgs.go_1_22 and pkgs.go_1_21 (after a lot of trial and error) but no others.
REQUEST
make golang compatible with specific pinned language versions, just like many other languages already supported are.
Someone needs to create nixpkgs-go with all the versions packaged :)
To find the version of go is not an issue. You can refer to this: https://lazamar.co.uk/nix-versions/?channel=nixpkgs-unstable&package=ffmpeg @domenkozar
However, devenv can not deal with it. It says it can't find buildGoModule with version 1.20.14 :cry:
When versions are available for a language (and I can see them with devenv search, how do I figure out what the actual package name is for the package with version?
Please upvote this issue if it's important to you and we'll get it done.
Package name should be in the output of devenv search, you can see it prefixed with pkgs..
Package name should be in the output of devenv search, you can see it prefixed with pkgs..
But how do I specify the version that I see there? For example, there is
| pkgs.go | 1.22.3 | Go Programming language |
How do I know that this is specified with underscores this way?
languages.go.package = pkgs.go_1_22;
When I try to do this to set languages.cue.package I don't know what the exact format is.
There's:
+------------------------------------------------+---------+----------------------------------------------------------------------------------+
| pkgs.go_1_22 | 1.22.3 | Go Programming language |
+------------------------------------------------+---------+----------------------------------------------------------------------------------+
So languages.go.package = pkgs.go_1_22; should work.
Same goes for cue, if the version is available.
| pkgs.cue | 0.9.2 | Data constraint language which aims to simplify tasks involving defining and usi |
Maybe its a problem with zeros- I tried some different variations for languages.cue.package and none worked.
I haven't tried devbox, but they have clear documentation on how to specify package versions: https://www.jetify.com/devbox/docs/guides/pinning_packages/
The issue I have with this approach is that you'll get also an outdated closure, possibly with security issues in the closure like openssl.
If someone is interested to sponsor nixpkgs-go creation I could do that in similar style like https://github.com/cachix/nixpkgs-python that auto-updates each hour.
Looks like @purpleclay started some of this in https://github.com/purpleclay/go-overlay
Looks like @purpleclay started some of this in https://github.com/purpleclay/go-overlay
I have finally got something up and running. If this helps anyone, then great!
Thanks @purpleclay, I've integrated your overlay at https://github.com/cachix/devenv/pull/2340
I'm getting:
error: at «github:cachix/devenv-nixpkgs/dcf61356c3ab25f1362b4a4428a6d871e84f1d1d»/pkgs/build-support/go/module.nix:225:47:
224|
225| CGO_ENABLED = args.env.CGO_ENABLED or go.CGO_ENABLED;
| ^
226| };
error: attribute 'CGO_ENABLED' missing
Using go 1.23.0, maybe too new/old nixpkgs?
Just saw this. I can take a look.
Here's what Claude is saying:
● Here's the mk-go-toolchain.nix from go-overlay. The fix needed is to add the missing attributes. The derivation should include:
inherit (stdenv.targetPlatform.go) GOOS GOARCH; CGO_ENABLED = if stdenv.targetPlatform.isWasi || (stdenv.targetPlatform.isPower64 && stdenv.targetPlatform.isBigEndian) then 0 else 1;
Options:
- Fix in go-overlay (recommended) - Add these attributes to mk-go-toolchain.nix. This makes go-overlay packages compatible with nixpkgs' buildGoModule. I can draft a PR.
- Fix in nixpkgs - Make buildGoModule provide defaults when go.CGO_ENABLED is missing. However, this is a workaround for an external overlay, which might not be accepted upstream.
Which would you prefer? I can help draft a PR for go-overlay.
On Sat, Dec 13, 2025 at 4:28 PM Purple Clay @.***> wrote:
purpleclay left a comment (cachix/devenv#1179) https://github.com/cachix/devenv/issues/1179#issuecomment-3649541468
Just saw this. I can take a look.
— Reply to this email directly, view it on GitHub https://github.com/cachix/devenv/issues/1179#issuecomment-3649541468, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA63A7YVTCETLRJ7V5EU6L4BQWDVAVCNFSM6AAAAACNAW72KWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTMNBZGU2DCNBWHA . You are receiving this because you were mentioned.Message ID: @.***>
Raised: https://github.com/purpleclay/go-overlay/issues/38 will fix it now
Fix has been merged in. Let me know if that addresses your issue @domenkozar
Thanks!!