Home Manager and Nixpkgs Version Mismatch

How do I resolve the following warning when I run sudo nixos-rebuild switch --upgrade or sudo nixos-rebuild switch --flake '/etc/nixos#nixos'?

building the system configuration...
evaluation warning: samir profile: You are using

                      Home Manager version 25.05 and
                      Nixpkgs version 24.11.

I have the following /etc/nixos/configuration.nix:

{ config, pkgs, ... }:

{
  imports =
    [ # Include the results of the hardware scan.
      ./hardware-configuration.nix
    ];

...
}

/etc/nixos/flake.nix: (source)

{
  description = "NixOS configuration";

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

  outputs = inputs@{ nixpkgs, home-manager, ... }: {
    nixosConfigurations = {
      nixos = nixpkgs.lib.nixosSystem {
        system = "x86_64-linux";
        modules = [
          ./configuration.nix
          home-manager.nixosModules.home-manager
          {
            home-manager.useGlobalPkgs = true;
            home-manager.useUserPackages = true;
            home-manager.users.samir = import ./home.nix;
          }
        ];
      };
    };
  };
}

/etc/nixos/home.nix: (source)

{ config, pkgs, ... }:

{
  home.username = "samir";
  home.homeDirectory = "/home/samir";

  home.stateVersion = "24.11";

  programs.home-manager.enable = true;
}

Finally,

$ sudo nix-channel --list
home-manager https://github.com/nix-community/home-manager/archive/release-24.11.tar.gz
nixos https://nixos.org/channels/nixos-24.11

Thanks
Samir

Hi there and welcome!

First of all I want to give a small hint, when using flakes your channel related commands might not be doing what you expect them to do, aka they do no longer influence your system config.
You might want to set up your NIX_PATH to use the nixpks input of your flake, so that stable nix commands use the same nixpks revs like the unstable (flake) ones. In a ā€œflake worldā€ the inputs ā€œreplaceā€ the channels (or in other words flake donā€™t use the channels)

About your issues:
When taking a careful look at your flake inputs, one will notice that there is no branch mentioned for the home manager input. That will result in picking the default one which is master and that matches up to nixos-unstable.
As your nixpks input is nixos-24.11 (so stable), that is the source of the error message.

As for your channels you tried to pick stable home manager, your should update the home manager input to

home-manager.url = "github:nix-community/home-manager/release-24.11"

That should update the flake.lock (as the URL changed) and the warning should be gone.

1 Like

This is a problem people have been running into for years that hasnā€™t been addressed in community communication and documentation, not sure why.

The version mismatch is merely a symptom of that: Including Home Manager from Nixpkgs is upside-down, IMHO, because Home Manager is already building on top of some version of Nixpkgs (there are tests and appropriate release branches etc.). So at least for regular Linux distributions, instead Iā€˜d recommend picking the exact Nixpkgs a given Home Manager release uses, and generally thinking of Home Mananager as a standalone application that uses Nixpkgs and Nix underneath, not some nice add-on to Nix or Nixpkgs.

(Practically this means using follows in flakes; stable Nix is currently hosed because thereā€™s no backward compatible interface upstream and one has to do atrocious things such as reading flake.lock.)

This gets slightly more complicated with NixOS, because NixOS is definitely a standalone application on top of Nixpkgs. It so happens that Nixpkgs and NixOS live in the same source tree, such that in practice you can build your NixOS from the Nixpkgs that ships with Home Manager, but that sounds and feels wrong to me. This is why I prefer to keep the two entirely separate.

In both cases youā€™re left with trusting Home Manager maintainers to stay close to Nixpkgs release branch tips for security patches to reach you timely, or, as you do now, keep Nixpkgs references up to date yourself and absorb the maintenance burden of ensuring compatibility.

There are lengthy discussions around HM and NixOS being separate things to begin with, but reality is messy and itā€™s not particularly cheap to change the status quo.

1 Like

Thank you. I am still very new to NixOS and read about the use of channels in the manual to keep my system up to date but did not realize that what channel I am following isnā€™t relevant when using flakes.

Apologies but Iā€™m not sure I follow what you are suggesting here. Can you please elaborate? Currently, I have:

$ echo $NIX_PATH
nixpkgs=flake:nixpkgs:/nix/var/nix/profiles/per-user/root/channels

Thank you. Your suggestion to use home-manager.url = "github:nix-community/home-manager/release-24.11" indeed addressed the warning.

Alternatively, it looks like if I want to use the unstable or master branch, I would have to use the following URLs in my /etc/nixos/flake.nix to keep things consistent:

nixpkgs.url = "github:nixos/nixpkgs";
home-manager.url = "github:nix-community/home-manager";

Thanks again for the quick and very helpful reply!

Thanks for your response. Even though I have been using Ubuntu for around a decade, I am have only been experimenting with NixOS for a week or so in a virtual machine so Iā€™m still trying to learn what the best approach to set up my system is:

  • Do I even need to use Home Manager?
  • If so, do I set it up standalone or as a NixOS module?
  • Do I install it via flakes?

I know there are advantages and disadvantages to all of these approaches but I just need to better understand them.

Thanks
Samir

Iā€™d recommend to always mention the branch you want to use in the urls of the flake inputs, otherwise you might have just implicit selected what you want to download, and it might change if the default branch changes.
Aside that in most of the times you never want to use nixpks/master as input (which would be the case in nixpkgs.url = "github:nixos/nixpkgs";).

But aside that you are correct.

Apologies but Iā€™m not sure I follow what you are suggesting here. Can you please elaborate?

You could read something like that for explanation Custom NIX_PATH and Flake Registry | NixOS & Flakes Book

Tho that is not the deal breaker (I just found it important for my personal setup) and as you pointed you that you are new to nixos Iā€™d recommend to leave it on the defaults (and maybe you didnā€™t even need to care about that at all).

Makes sense. Just for completeness then: If I wanted to follow unstable, would the correct URLs to use be:

nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
home-manager.url = "github:nix-community/home-manager";
               # or github:nix-community/home-manager/master?

Thank you for the suggestion! I had that site bookmarked previously but will try to get to it sooner rather than later!

Currently both are the same, as the default branch for home-manager repo is master
if you want to explicitly name the branch, then you want to use

nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
home-manager.url = "github:nix-community/home-manager/master";

If you trust that the default branch will never change (which will possibly true but who knows :slight_smile:) both are effectivly the same.

Tho you should switch from nixpkgs-unstable to nixos-unstable as the nixpkgs-unstable is not running all tests that are kind of relevant for nixos, so you might end up in a situation, that the binary cache will miss (a lot/some) programs,

AFAIK nixpkgs-unstable is often used by users that have non-nixos setups (e.G nix-darwin or just nix on another linux distro). But even then using nixos-unstable as source should not hurt (it will likely just be a bit behind nixpkgs-unstable).

1 Like

Thank you again for your helpful replies! I really appreciate you taking the time to help out a newcomer to the community!

1 Like