Can't install go_1_18

I’m trying to install go_1_18 globally in my system. I added the entry to my configuration file, and after trying to rebuild with switch, the following error pops-up:

building Nix...
building the system configuration...
error: undefined variable 'go_1_18' at /etc/nixos/configuration.nix:116:5
(use '--show-trace' to show detailed location information)

Output of nix-channel --list:

nixos https://nixos.org/channels/nixos-unstable

When I try to run nix-env -iA nixos.go_1_18 it works. Any ideas?

It depends on your configuration.nix, but “normally” packages aren’t in top-level scope. Typically you’d write pkgs.go_1_18.

Got:

unpacking 'https://github.com/nix-community/home-manager/archive/master.tar.gz'...
building Nix...
building the system configuration...
error: attribute 'go_1_18' missing, at /etc/nixos/configuration.nix:116:5
(use '--show-trace' to show detailed location information)

Are you sure that you’re evaluating with sufficiently new NixPkgs version? 1.18 is relatively new. (I’m not really familiar with home-manager.)

Can you elaborate what that means and how I can find out that? I switched from Arch to NixOS two weeks ago. I’m still going through the documentation.

This smells like the usual user channels, root channels and actual channel state confusion.

nix-channel != sudo nix-channel and what’s in the channels list doesn’t necessarily match what the channel is like on-disk (only after --update!).

Make sure you know which user’s channels you’re using and what their actual state is.

1 Like

That comment didn’t really help me :confused:. Can you please elaborate?

Both root & my user are pointing to the unstable channel. In fact I can install go_1_17, but not go_1_18.

nv, managed to understand and fix it. Thank you!