mherzl
mherzl

Reputation: 6200

I changed my nixos channel to unstable, why are my packages still not updated?

How do I update my packages from the nixos-18.09 channel to the nixos-unstable channel? I am trying to do this as I need to use updated versions of some packages.

Following the directions in the nixos manual, I have added the nixos-unstable channel https://nixos.org/channels/nixos-unstable, removed the nixos-18.09 channel https://nixos.org/channels/nixos-18.09, and run $ nix-channel --update and $ sudo nixos-rebuild switch --upgrade.

Still, however, my installed packages are the old versions. I have also tried $ nix-env -u '*' and still have the old versions. What else do I need to do to update my packages to the nixos-unstable versions?

Upvotes: 1

Views: 4319

Answers (3)

Daniel Staleiny
Daniel Staleiny

Reputation: 434

If you want to change all the packages to unstable

{ pkgs, ... }@args:
let
  pkgsUrl = "https://github.com/NixOS/nixpkgs-channels/archive/nixos-unstable.tar.gz";
  pkgs = import (builtins.fetchTarball pkgsUrl) {};
in
{...}

Upvotes: 0

Chris Stryczynski
Chris Stryczynski

Reputation: 33891

I am trying to do this as I need to use updated versions of some packages.

You can use packages from different channels. So possibly keeping your default channel as stable, and just referencing particular packages from the unstable channel might be a better solution.

I have the following import in my config (using google-chrome from the channel I have assigned to unstable):

{ config, pkgs, ... }:


let
  unstable = import <unstable> {
    config = config.nixpkgs.config; 
  };
in
{
   environment.systemPackages = with pkgs; [
     awscli
     google-cloud-sdk
     kubectl
     libreoffice
     # ...
     unstable.google-chrome
   ];
}

As to why your packages are not using the unstable channel, probably because they reference the nixos channel which you did not seem to modify (you seemed to only add a channel named nixos-unstable, but nothing referenced this channel name most probably).

Upvotes: 6

Emmanuel Rosa
Emmanuel Rosa

Reputation: 9885

To change to the unstable NixOS channel:

  1. Become root; You want to change the root user's Nix channel: su
  2. Remove the NixOS channel: nix-channel --remove nixos
  3. Add the NixOS unstable channel and ensure it's named nixos: nix-channel --add nixos https://nixos.org/channels/nixos-unstable

Then you can upgrade as you normally would. For example, nixos-rebuild --upgrade boot will first update the NixOS channel and then install packages from the updated channel. Upon reboot you'd be updated.

Note: I advise against doing nixos-rebuild --upgrade switch, especially when changing channels, simply because NixOS won't restart all services anyway. Therefore the switch would be incomplete.

Upvotes: 2

Related Questions