I have installed vs code in nixos, and it shows that there is an available update but it does not update automatically. I have tried running sudo nixos rebuild switch --upgrade
but it doesn’t seem to update vs code to latest version. How to I update it then?
Are you running flakes? Or what does your setup look like?
Ok, if not, my understanding is that sudo nix-channel --update
should do the trick. I’m fairly new to nix, and started with flakes from day one, so I don’t use this method.
If on flakes, nix flake update
Then rebuild in both scenarios.
Depending on the channel you use you might already have the latest available version.
1.78.2 for 23.05, 1.80.1 for unstable, where unstable seems to be on-par with the latest release notes.
How do I use the unstable channel?
EDIT: Ok, ChatGPT helped me:
sudo nix-channel --add https://nixos.org/channels/nixos-unstable nixos-unstable
sudo nix-channel --update
sudo nixos-rebuild switch --upgrade
I hope this is right?
EDIT 2: It didn’t work…
What exactly does not work?
What you did with the nix-channel
commands was to add another channel, unless you install VScode from that explicitely, nothing does change…
So either replace the roots nixos
channel with unstable to upgrade the whole system to use unstable or use the nixos-unstable
channel via import <nixos-unstable> { config.allowUnfree = true; system = …; }
explicitely where you need it.
PS: Please do not rely on GPT for things related to the nix ecosystem… There is always a lot of outdated information mixed with even more halluzination. You need to have a lot of experience to identify its dreams as such and push it towards a viable solution. Please ask here or in the matrix or the inofficial discord.
Hello NoobZ! Thanks for your response.
After extensive searching with GCTE (Google & ChatGPT & Trial & Error), I hit a roadblock with the “allowUnfree” configuration. Despite trying various placements, I overlooked its inclusion in the import
statement. Your advice was invaluable—thank you!
Eventually, I managed to update my VS Code using this approach:
let
unstable = import <nixos-unstable> { config.allowUnfree = true; };
in
{
...
nixpkgs.config = {
allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
"vscode-1.84.2"
];
packageOverrides = pkgs: {
vscode = unstable.vscode;
};
}
Initially, I was unsure of what I was doing, but now I’m sure I have no idea! But… it’s successfully working!