nixnixoshome-manager

How can I make home-manager use nixpkgs-23.11 in flake system configuration?


My flake.nix in /etc/nixos directory:

{
  description = "A very basic flake";

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

  outputs = { self, nixpkgs, home-manager, ... }@inputs:
  let
    system = "x86_64-linux";
    pkgs = import nixpkgs {
      inherit system;
      config.allowUnfree = true;
    };
  in {
    nixosConfigurations = rec {
      default = nixpkgs.lib.nixosSystem {
        specialArgs = { inherit inputs system; };
        modules = [ ./configuration.nix home-manager.nixosModules.home-manager ];
      };

      nixos = default;
    };
  };
}

When I run it (installing home-manager for the first time), I get this log:

warning: creating lock file '/etc/nixos/flake.lock'
building the system configuration...
trace: warning: monkpatch profile: You are using

  Home Manager version 24.05 and
  Nixpkgs version 23.11.

Using mismatched versions is likely to cause errors and unexpected
behavior. It is therefore highly recommended to use a release of Home
Manager that corresponds with your chosen release of Nixpkgs.

If you insist then you can disable this warning by adding

  home.enableNixpkgsReleaseCheck = false;

to your configuration.

And if I replace nixos-23.11 with nixos-unstable in nixpkgs.url (line 5), then the error disappears. But what if I want to use nixos-23.11? What do I do?


Solution

  • The home-manager git repository happens to have a release-23.11 branch that corresponds with the nixos-23.11 branch of nixpkgs. Line 5 of your flake.nix even provides a clue on how to specify git branches:

        nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11";
    

    In other words, the flake "URL" syntax for branches is just to add another / and then the branch name. Modify line 7 of your flake.nix to read

          url = "github:nix-community/home-manager/release-23.11";
    

    and you should be good to go!