How to upgrade packages

  1. sudo nix-channel --update
    unpacking channels…

  2. sudo nixos-rebuild switch
    building Nix…
    building the system configuration…
    updating GRUB 2 menu…
    activating the configuration…
    setting up /etc…
    reloading user units for radek…
    setting up tmpfiles

  3. nix-env -u ‘*’


  1. Do nothing??? I can see that XFCE 4.14 is avalaible… why the last command does not upgrade packages???

nix-env is an imperative method of updating packages similar to apt install and won’t change your system configuration. XFCE is likely installed as a system thing. Look at “nix-env -q” to see what nix-env is managing.

The first two commands do update your system. It is root’s channel that usually matters. You are probably using a channel, so take a look at “sudo nix-channels —list”

1 Like

What channel(s) are you on? sudo nix-channel --list

Perhaps you are just on an old channel that doesn’t have that version? Remember that there is always only a single version of nixOS supported…

Also perhaps show relevant parts of your configuration.nix.

iam using nixos-19.09 the last channel

[root@nixos:/home/radek]# nix-env -qa chromium
i have installed 122 version and cant upgrade to 132
[root@nixos:/home/radek]# nix-env -qa libreoffice
and xfce 4.14 i have installed 4.12

nix-env -u, nix-env -u '’ does not upgrade packages…
nix-env -u chromium or libreoffice xfce4-
also does not work

sudo nixos-rebuild switch --upgrade? I’m not sure it does anything more than the first two commands but it’s worth a shot


I don’t use nix-env for anything, I do only install via respective means of configuration.nix and home.nix.

Or one-off via nix run or in a shell.nix defined environment.

So far I never had problems updating anything.

How have you checked your version of xfce and how did you install it?

Did you perhaps installed it twice? Once via configuration.nix and once via nix.env? Or worse, only via nix-env and hardcoding the path in some config files to make you able to start it?

Enable the KDE Desktop Environment.

services.xserver.displayManager.lightdm.enable = true;
services.xserver.desktopManager = {
xfce.enable = true;
default = “xfce”;

XFCE 4.12 is installed via configuration.nix

XFCE 4.14 is enabled in channel 19.09
for example
nix-env -qa xfce4-panel

Im new in nixos and I am trying to figure out how it works

From looking at the available options, it seems as if xfce 4.14 has been added as a different option.

From some comment in the defining file, it seems as if this is to avoid confusion of users:

  # added 2019-08-18
  # needed to preserve some semblance of UI familarity
  # with original XFCE module

Though I’m not sure why your nix-env installed stuff is not updated.

Had the same question so putting it here too in case it helps:


  1. Are you on the latest channel?
    (See how to check and set below.)

  2. sudo nix-channel --update

  3. a. (declarative/NixOS) sudo nixos-rebuild switch
    b.                   (ad-hoc) nix-env -u '*'
    c.     (Home Manager) home-manager switch (I think)

These steps should work regardless of using NixOS or not.

NOTE: Don’t know how flakes work, but it’s a fairly good bet that this won’t work with them.

Step 0. Check and set the latest channel

Step 1.'s nix-channel --update will only pull the changes in the channel that is currently set! To check the current one you are subscribed to, issue

sudo nix-channel --list

The latest NixOS manual’s Chapter 4. Upgrading NixOS will always show the name and the link of the latest channel. The Nix Channel Status page is also a very good resource.

For example, I was subscribed to channel 20.09 so I needed to update it to 21.11 by doing

$ sudo nix-channel --list

$ sudo nix-channel --remove nixos
$ sudo nix-channel --add nixos

More info:

  • The Nix manual’s 4.4 Channels section is a short intro to Nix channels.

  • The NixOS wiki’s Nix channels article goes more into the details and has a good summary on the basic commands. (Personally, I found this one more useful.)

Step 1. Update the channel

This is required both for declarative and “ad-hoc” [sic] setups3:

sudo nix-channel --update

Even though the Nix manual has a 4.1 Basic Package Management section, it is best documented in the NixOS manual (see Chapter 7. Package Management). (Albeit, I didn’t find it straightforward figuring out the correct order of steps from these; the biggest help was this NixOS discourse thread.)

Home Manager does not seem to complicate this process. (At least, I’m using it on NixOS, and nixos-rebuild switch always takes care of everything with my setup.)

The nixos-rebuild switch --upgrade combines Step 1. and Step 2. as it "is equivalent to the more verbose nix-channel --update nixos; nixos-rebuild switch".

Step 2. Update the packages

The two adjectives, “ad-hoc” [sic] and “declarative”, are introduced in the NixOS manual to differentiate the two modes of Nix package management3:

  • ad-hoc”: Managing packages with nix-env.1

  • declarative”: In the NixOS manual, this refers to declaring packages as a list in NixOS’ configuration.nix, but it can be done in many other ways2.

The commands:

a. To update all packages declared in NixOS’ configuration.nix, use:

sudo nixos-rebuild switch

b. To update all packages installed with nix-env:

nix-env -u '*'

c. To update all packages installed using Home Manager:

home-manager switch

(I think. Again, I’m using Home Manager in NixOS, and never had to touch any Home Manager commands. See Home-manager equivalent of “apt upgrade”)


[1]: As far as I know, the NixOS manual is the only official document that uses the term “ad-hoc [sic] package management” and only to mean package management using nix-env.

(Therefore I find the term misleading, because using packages via nix-shell -p commands or custom shell.nix-es are also ad hoc forms of package management. Also, nix-env can be messy.)

[2]: For example with Home Manager, using shell.nix-es, flakes. (It is probably incorrect to list flakes, as it is a mechanism that can be used with Home Manager and nix-shell Nix expressions…)

[3]: Not sure if there is a consensus what “ad-hoc”, “declarative”, and “imperative” package management means in Nix; footnote 1 has my thoughts about “ad-hoc”, some say that using channels is always an imperative form of package management, so “declarative” seems to be overloaded…


I have the same issue, all options presesnted do not work, and nixos-rebuild --upgrade boot also does not. I am trying to switch to unstable

Same issue here. Anyone resolve?

Are you sure nixos-rebuild actually did something?

Its verbose output could hide a non blocking fatal error (:woman_facepalming: ) like a lack of free disk space

agreed. However, I did find that it would update the core OS and bundled services. Installed packages however, no, I have yet to see a single one update, even when checking logs no errors are found even when setting to verbose.

What kind of packages that are not updated are you referring to? Did you install them from the NixOS configuration file?

If you installed stuff from nix-env or nix profile, it’s unrelated to the command nixos-rebuild (and I know it’s confusing)

You’re right. I am confused now. (New to NixOS). I both placed the packages in the configuration.nix and for a few items I added them via the nix-env command. But I did think they would do the same thing. It was only the nix-shell commands that I thought did not work the same.

I have tried all of the steps above (sans Home-manager method since I am not using that). But nothing updates from what I can tell. All of my packages:

Microsoft Teams
Visual Studio Code

all remain out of date.

But if I’ve been doing this wrong this whole time, I’d love to know the correct way.

Unfortunately, using nix-env on NixOS is wrong in almost all cases. People still run into instructions to use nix-env by default, because it’s the first practical thing to encounter in the Nix manual.

I’m really sad to read that it has cost you so much time and caused such frustration. Sorry that I still didn’t manage to implement the change to the manual the Nix maintainer team has long approved. I’ll put some effort into it again after NixCon. Remove Package Management chapter · Issue #7769 · NixOS/nix · GitHub

For a concrete solution attempt, you could check what takes precedence in your $PATH. May well be that the imperatively installed packages shadow the ones provided by NixOS.