Question regarding package updates

I recently had a question about kernel updates on NixOS which was answered here.

As I am still new to NixOS am still a bit confused when it comes to package updates. I have configured my system to use the “nixos-unstable” channel.

When I upgrade I followed the instructions listed here. So by running the following command.
nixos-rebuild switch --upgrade

When I take for example the fastfetch package on my system to see which version I have I see the following.

fastfetch --version
fastfetch 2.14.0 (x86_64)

However when I check search.nixos.org and look up fastfetch version I see a different version listed for the unstable channel fastfetch: 2.15.0. But that version is not installed on my system. What am I still missing here when it comes to updates?

I don’t know if this is useful information but it seems like it. I’m using a Flake that looks like this, based on the example I saw in the home manage manual.


{
  description = "NixOS flake";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    home-manager.url = "github:nix-community/home-manager";
    home-manager.inputs.nixpkgs.follows = "nixpkgs";
  };

  outputs = { self, nixpkgs, home-manager, ... }@inputs: {
    nixosConfigurations.lilith = nixpkgs.lib.nixosSystem {
      system = "x86_64-linux";
      modules = [
        # Import the previous configuration.nix we used,
        # so the old configuration file still takes effect
        ./configuration.nix
        home-manager.nixosModules.home-manager
        {
            home-manager.useGlobalPkgs = true;
            home-manager.useUserPackages = true;
            home-manager.users.cphusion = import ./user/cphusion-home.nix;
        }
      ];
    };
  };
}

I figured out my problem because I am using a flake there is an extra step. I have to update my flake.lock file by running.
# nix flake update

After which I can run the upgrade.
# nixos-rebuild switch --upgrade

Now when I check fastfetch, I have the same version installed as listed on search.nixos.org for the unstable channel.

fastfetch --version
fastfetch 2.15.0 (x86_64)

So my problem and confusion are resolved.

The --upgrade is only confusing you. It’s pulling a channel (nix-channel), but you’re using flake instead of the channel.

1 Like

@vcunat Thanks for your reply! So is my conclusion correct, that I first have to run “nix flake update” and then " nixos-rebuild switch --upgrade" or is there a better way of doing it?

Or is all I need to do run “nix flake update” and then run “nixos-rebuild switch” since everything is updated through the flake?

You could drop the --upgrade. You don’t need it for flake stuff.

2 Likes

I appreciate your help and explanation! Thanks for your help!

1 Like

@anon39437090 SYN :vulcan_salute:

I’m very new to NixOS, too; I have been using it for less than two months! Because I had some free time, I’ve been learning Nix and NixOS nonstop; I can’t get enough of them.

I remember reading somewhere a reply someone left to a post about configuration management tools (e.g., Ansible, Chef, Salt) and how they stitched them to other toolsets to achieve granular management of their infrastructure. This person replied along the lines, “So, you’re achieving less than what Nix is capable of doing, with a lot more of effort and tools.” – nailed it. Nix, and by extension NixOS, are sweet, the good stuff :smile:

So, check below these links that hopefully will help you get started as fast as possible:

Just to name a few to get you started, there are tons of great content about Nix and NixOS on YT.

It would help if you also spend some time at:

https://nixcloud.io/tour/

and

Last, my ongoing (and forever WIP, I’m realizing) flake where I’m applying all the stuff I’m learning:

One interesting thing about my flake is that I’m using the nixos-24.05 release channel for the “mission critical” stuff–that is all I consider the “infrastructure” part of my systems (system utilities, configurations, graphical stack, DE/WM stuff, and so on) while using nixos-unstable for everything else.

3 Likes

I have been using NixOS for 8 days now. I ran it in a vm for a day and the next day I reinstalled my desktop with NixOS :slight_smile: I am very happy with it!

I already have some of the links you shared bookmarked and Youtubers but will have a look at the ones that I didn’t have yet.

I run NixOS on my desktop so I’m not sure how deep I will go into it but it would be cool to learn how to write some of my own modules so that looks useful.

I have already put my configuration in my Git repo and made it modular in case I want to do anything with it.

I’ll just share the links I have that I found useful when it comes to information about NixOS, for anyone new to NixOS that comes across this topic.

https://nixos.org/manual/nixos/stable
https://nlewo.github.io/nixos-manual-sphinx/index.html
https://nix.dev/manual/nix/2.18/command-ref/new-cli/nix
https://nix.dev/manual/nix/2.18/command-ref/nix-env
https://nix-community.github.io/home-manager

https://wiki.nixos.org/wiki/NixOS_Wiki
https://search.nixos.org/packages
https://search.nixos.org/options
https://home-manager-options.extranix.com

3 Likes