Error when add home-manager -> flake.nix [resolved]

Hi everyone,

I followed a video tutorial (LibrePhoenix) but made some modifications because we do not use the same channel and when I updated flake.nix I had :

[15:05:17]  gg  on nixos ~/.dotfiles
➜ home-manager switch --flake .
warning: updating lock file '/home/gg/.dotfiles/flake.lock':
• Added input 'home-manager':
    'github:nix-community/home-manager/086f619dd991a4d355c07837448244029fc2d9ab' (2024-08-11)
• Added input 'home-manager/nixpkgs':
    'github:NixOS/nixpkgs/5e0ca22929f3342b19569b21b2f3462f053e497b' (2024-08-09)
• Added input 'home-manager-unstable':
    'github:nix-community/home-manager/086f619dd991a4d355c07837448244029fc2d9ab' (2024-08-11)
• Added input 'home-manager-unstable/nixpkgs':
    follows 'nixpkgs'
error:
       … from call site

         at /nix/store/fwd43fbjjpdkirilf7m6gjq4gvny5jjs-source/flake.nix:26:12:

           25|     homeConfigurations = {
           26|       gg = home-manager.lib.homeManagerConfiguration {
             |            ^
           27|         inherit pkgs-unstable;

       error: function 'homeManagerConfiguration' called without required argument 'pkgs'

       at /nix/store/04ia5664ancpy3q9rb7dwy9xxafqnmk3-source/flake.nix:41:36:

           40|         hm = (import ./modules/lib/stdlib-extended.nix nixpkgs.lib).hm;
           41|         homeManagerConfiguration = { modules ? [ ], pkgs, lib ? pkgs.lib
             |                                    ^
           42|           , extraSpecialArgs ? { }, check ? true

I don’t understand the errors. Here is my flake.nix :

{

  description = "A very basic flake";

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

  outputs = { self, nixpkgs, home-manager, ... }:
    let
      lib = nixpkgs.lib;
      system = "x86_64-linux";
      pkgs-unstable = nixpkgs.legacyPackages.${system};
    in {
    nixosConfigurations = {
      nixos = lib.nixosSystem { 
        inherit system;
        modules = [ ./configuration.nix ];
      };
    };
    homeConfigurations = { 
      gg = home-manager.lib.homeManagerConfiguration { 
        inherit pkgs-unstable;
        modules = [ ./home.nix ];
      };
    };
  };

}

A little help would be welcome.

The homeManagerConfiguration function expects an object with a pkgs property. Using inherit pkgs-unstable; is equivalent to pkgs-unstable = pkgs-unstable;, but the function requires pkgs, not pkgs-unstable.

To fix this, change inherit pkgs-unstable; to pkgs = pkgs-unstable;. This will resolve the issue.

homeConfigurations = {
  gg = home-manager.lib.homeManagerConfiguration {
    pkgs = pkgs-unstable;
    modules = [ ./home.nix ];
  };
};
1 Like

Resolved.
Thank you @pan93412.

1 Like