How can I use the Nix unstable channel to install the latest Go toolchain?

Hi,

This is the first time I edit replit.nix and replit files, so maybe I fail to see the obvious.

I want to install the latest Go (“golang”) toolchain for my Repl. The Nix package “go_1_19” is available in the “unstable” channel, so I edited the config files as follows.

In .replit, I set the channel name to “unstable”:

[nix]
channel = "unstable"

replit.nix contains the following:

{ pkgs }: {
    deps = [
        pkgs.go_1_19
        pkgs.gopls
    ];
} 

However, when (re-)starting the Repl, I get this output in the console:

nix error: building nix env: exit status 1
Output has been trimmed to the last 20 lines
evaluating file '/nix/store/yi8wmqfvfiz2w9wjapvpilma2a1rq7k2-nixpkgs-unstable-src/pkgs/top-level/stage.nix'
evaluating file '/nix/store/yi8wmqfvfiz2w9wjapvpilma2a1rq7k2-nixpkgs-unstable-src/pkgs/stdenv/adapters.nix'
evaluating file '/nix/store/yi8wmqfvfiz2w9wjapvpilma2a1rq7k2-nixpkgs-unstable-src/pkgs/build-support/trivial-builders.nix'
evaluating file '/nix/store/yi8wmqfvfiz2w9wjapvpilma2a1rq7k2-nixpkgs-unstable-src/pkgs/top-level/splice.nix'
evaluating file '/nix/store/yi8wmqfvfiz2w9wjapvpilma2a1rq7k2-nixpkgs-unstable-src/pkgs/top-level/all-packages.nix'
evaluating file '/nix/store/yi8wmqfvfiz2w9wjapvpilma2a1rq7k2-nixpkgs-unstable-src/pkgs/top-level/aliases.nix'
evaluating file '/nix/store/yi8wmqfvfiz2w9wjapvpilma2a1rq7k2-nixpkgs-unstable-src/pkgs/stdenv/generic/default.nix'
evaluating file '/nix/store/yi8wmqfvfiz2w9wjapvpilma2a1rq7k2-nixpkgs-unstable-src/lib/customisation.nix'
evaluating file '/nix/store/yi8wmqfvfiz2w9wjapvpilma2a1rq7k2-nixpkgs-unstable-src/pkgs/tools/text/gawk/default.nix'
evaluating file '/nix/store/yi8wmqfvfiz2w9wjapvpilma2a1rq7k2-nixpkgs-unstable-src/pkgs/servers/x11/xorg/default.nix'
evaluating file '/nix/store/yi8wmqfvfiz2w9wjapvpilma2a1rq7k2-nixpkgs-unstable-src/pkgs/servers/x11/xorg/overrides.nix'
evaluating file '/nix/store/yi8wmqfvfiz2w9wjapvpilma2a1rq7k2-nixpkgs-unstable-src/pkgs/stdenv/generic/make-derivation.nix'
evaluating file '/nix/store/yi8wmqfvfiz2w9wjapvpilma2a1rq7k2-nixpkgs-unstable-src/pkgs/build-support/mkshell/default.nix'
evaluating file '/home/runner/playground/replit.nix'
evaluating file '/nix/store/yi8wmqfvfiz2w9wjapvpilma2a1rq7k2-nixpkgs-unstable-src/pkgs/stdenv/generic/check-meta.nix'
evaluating file '/nix/store/yi8wmqfvfiz2w9wjapvpilma2a1rq7k2-nixpkgs-unstable-src/lib/systems/doubles.nix'
copied source '/nix/store/yi8wmqfvfiz2w9wjapvpilma2a1rq7k2-nixpkgs-unstable-src/pkgs/stdenv/generic/default-builder.sh' -> '/nix/store/9krlzvny65gdc8s7kpb6lkx8cd02c25b-default-builder.sh'
error: attribute 'go_1_19' missing, at /home/runner/playground/replit.nix:3:9
(use '--show-trace' to show detailed location information)
  • Is it possible to use the unstable channel for repls?
  • If so, what is wrong or missing in my setup?

Thanks

Hi @christophberger thanks for your message.

As far as I can see the unstable channel doesn’t contain go_1_19 however, if it did, you should be able to use it in your Repl as indicated above.

I don’t see go_1_19 in the unstable channel, only go… which is version 1.19.2… The error says go_1_19 is missing, I believe that’s because a package named so does not exist.

Thanks @IanAtReplit and @MattDESTROYER for replying.

Well, 16 days ago, when I raised this issue, go_1_19 did exist in the unstable channel, and I did of course try installing it as indicated above.

Think of it - would I otherwise have raised this issue here?

I am not sure why go_1_19 disappeared from the unstable channel and seems to be replaced by an unspecified “go” package. This does not exactly reinforce my trust in Nix as a reliable package manager.

With all due respect, my problem would not exist at all if Replit provided the latest stable version of Go (which is 1.19 since quite a while) for their Repls. Teaching Go with a horribly outdated version is not an option at all.

The version of Go in the default Go Repl is 1.17, I don’t know much about Go, but is the difference in versions really that significant that it makes using a slightly older version of Go unusable for teaching?

Also, this is in no way Replit’s fault. Replit uses Nix in order to support as many languages and packages as possible. Replit relies on Nix to provide the languages and modules it uses. It is surprising that the latest version of Go is not on Nix.

I’ve attempted to make a Repl with Go 1.19.2, I honestly don’t know how to check it actually is Go 1.19.2, but it runs without error so that’s something. Let me know if it helps. :slight_smile:

Just found out you can make packaging requests, it might be work making a packaging request for the latest version of Go.

Thanks @MattDESTROYER.

Having the latest version is absolutely important for teaching Go (or any other language). Last time I checked Replit, they were at Go 1.14 or so, which is ridiculous. It’s good if they have upgraded the Go Repl template to 1.17, but this version still misses some important language updates.

The latest Go version is available in Nix. It was labeled “go_1_19” 16 days ago and now it is labeled just “go”.

Screen Shot 2022-10-27 at 10.35.31

Seems that the Nix people take some liberty regarding renaming packages in the unstable channel. This is a surefire way of breaking existing Repl configurations.

I don’t say this is Replit’s fault. But if they rely on Nix, then Replit is no option for me.

Your repl runs Go 1.17.11.

Screen Shot 2022-10-27 at 10.36.57

I have no idea why this is so. I see you have configured the unstable channel and requested the “go” package (without a version suffix). The “go” package is at version 1.19.2 in the unstable channel and at version 1.17.13(!) in Nix channel 22.05 (but you did not even choose this channel). No idea where Go 1.17.11 comes from.

Apart from that, if the Nix team keeps the latest Go version in the unstable channel for weeks, if not months, and arbitrarily renames that package as they see fit, I see no way of reliably setting up a Replit configuration that always installs the latest Go version.

I really appreciate your efforts so far to help get this sorted. However, I should have clarified in my previous update today that I am no longer looking at Replit as a platform for teaching Go. As mentioned, my post is 16 days old, and I have decided to look elsewhere for a code teaching solution that meets my needs.

Fair enough, I’m sorry Replit didn’t suit your needs. I hope you find another platform that works better for teaching Go. Best of luck. :smile:

1 Like

Thanks @christophberger for your replies. I understand what you are saying about Nix changing the name of the package between you raising this as a query with the community. Unfortunately that is the downside of using an unstable channel - it changes. The stable channel should be more trustworthy.

Please feel free to provide feedback to Replit by clicking on the ? icon bottom left of any Repl and click on Share feedback . As you are at the front line in teaching Go to your students you understand exactly why you need to use Go 1.19 whereas other community members here might not. It would be useful if you could educate others in this community why specifically 1.19 is needed so that we can refer to this as a guide in the future.

Hi @IanAtReplit, thanks for your remarks.

A short comment on Nix: an unstable channel hosts packages that have not been tested enough by the maintainers to be considered stable. “Unstable” should not mean that the channel itself acts unpredictably.

But this forum is about Replit, so this comment shall be only an aside.

Regarding Go 1.19, there is nothing specific about this release, and I did not say so anywhere. What is important for teaching a language is to always have the latest version available. Languages evolve (even Go does), and when a new version comes out, users are curious about learning new and changed features of the language, the toolchain, and the standard library. If courses and learning paths cannot teach the latest language version at the time the version comes out, they will lose students.

Hi @christophberger thank you for your response. I appreciate the time you have taken to share your thoughts.

I think that, to be fair, language decisions differ from school to school / country to country, in my limited experience. It’s usually a calculated balance of what is accessible and supports the students to improve their computational thinking + coding practical skills. Curriculum standards are usually a slow moving ship and get updated every four years or so in my country (sometimes longer) so it is up to the school faculty to decide which language to teach their students and which resources to create / buy / use.

I only asked about Go 1.19 as you said that earlier versions missed some important language updates and I was curious what these were and how they related to your curriculum standards.

2 Likes