Updating packages

I don’t understand how to properly update packages, either the ones installed via configuration.nix nor the ones managed by home manager.

My system is built with flakes and home manager. I have some packages installed directly from the configuration.nix and others managed by home manager.

I tried as seen here and there on the net to update by running “nix flake update” and then “nixos rebuild switch” and “nix build .#homeManagerConfigurations…” and nix is doing things during theses commands but I see no difference, even after a reboot.

I have the i3status-rs package in version 0.22.0 installed via configuration.nix and the google-chrome package managed by home manager.
Theses are still outdated after the update while latest version are available in nixpkgs.
I tried to do a nix-shell -p i3status-rust and it opens a shell with the latest version 0.31.5 as intended but the system-wide version is still 0.22.0

What am I doing wrong ?

You’re installing NixOS 21.11, which is nearly 2 years out of date: https://github.com/JM445/config/blob/2e6e2666e2c83b7758656e5c7c532802ac9fe5da/nixdots/flake.nix#L5

You’ll have to do a distro upgrade. Fair warning, major releases are allowed to introduce breaking changes, and updating over 3 major releases will probably be a fair bit of work. You should read through the release notes of the last few versions: NixOS 23.05 manual | Nix & NixOS

You may want to do this incrementally, going over nixos-22.05 and nixos-22.11 as well, but you should ultimately change your inputs to:

inputs = {
  nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
  home-manager = {
      url = "github:nix-community/home-manager/release-23.05";
      inputs.nixpkgs.follows = "nixpkgs";

After that, nix flake update will in fact update your packages, until the next NixOS stable release, at which point you get to play this game again (just with much fewer breaking changes and fewer release notes to read).

Alternatively, you can install NixOS as a rolling release distro by using the unstable branches. Then you won’t need to do distro upgrades, and everything will always be very up-to-date, but you’ll probably run into breakage that prevents you from updating every once in a while.

FYI, while you can definitely use home-manager standalone, if you’re using NixOS and sync up the stable/unstable releases between the two anyway, you could also use the home-manager NixOS module, which saves you running a second command to update: Home Manager Manual

I say this especially because nix build .#homeManagerConfigurations… will only create a result directory with a profile that could hypothetically be installed as a home-manager setup, but not actually install it.

This is because nix-shell is one of the old nix commands, which still use channels. If you look at nix-channel --list, it will likely contain a channel pointing to NixOS 23.05.

If you intend to use flakes, I’d recommend removing that and any other channels (as well as the ones from sudo nix-channel --list), and instead use the nix shell command, which will use your flake registry, which you can in turn point at your system input. The nix flake registry will by default always use nixpkgs-unstable, hence you likely want to change that.

You can also make your flake set the nix path for backwards compatibility with non-flake commands like this.


Oh, I see the point.

I feel a little dump with the last two posts you answered. Thank’s for the help.

I was actually on 22.11, so the jump to 23.05 wasn’t that hard. This broke a few things but it will be easily fixed.

Nixos is so great but the learning curve is quite hard…