Flake and Home-manager 20.11 Configuration

Hello all,
New to nixOS, I’ve been trying to put together a bare minimum flakes and home-manager as a flakes module configuration, but I got a couple of errors:

 error: The 'homeManagerConfiguration' arguments

     - 'configuration',
     - 'username',
     - 'homeDirectory'
     - 'stateVersion',
     - 'extraModules', and
     - 'system'

   have been removed. Instead use the arguments 'pkgs' and
   'modules'. See the 22.11 release notes for more.

I went to the release notes and modified my flake.nix, but now I am getting another error:

error: flake 'path:/home/leigh/.flake' does not provide attribute 'packages.x86...
Did you mean homeManagerConfiguration?  

I have my configuration.nix and hardware-configuration.nix copied to a sub-folder, and I have a starter home.nix in my config folder in the home directory. Here’s my flake.nix. (The description is ironic given my current predicament.) If anyone has a word of advice, I’d be grateful. Thanks.

    {
  description = "Easy does it";

   inputs = {
    # Specify the source of Home Manager and Nixpkgs.

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

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


  outputs = inputs@{ nixpkgs, home-manager, ... }: 
  let
    system = "x86_64-linux";
    pkgs = import nixpkgs {
      inherit system;
      config = { allowUnfree = true; };
      };
      
    lib = nixpkgs.lib;

  in {

    nixosConfigurations = {
      nixbox = lib.nixosSystem {
      inherit system;
      modules = [
        ./system/configuration.nix
        home-manager.nixosModules.home-manager
        {
          home-manager.useGlobalPkgs = true;
          home-manager.useUserPackages = true;
          home-manager.users.leigh = import ./home.nix;
        }
      ];
      };    
    };
  };
}

What’s in your home.nix?

{ config, pkgs, ... }:

{
  # Home Manager needs a bit of information about you and the
  # paths it should manage.
  home.username = "leigh";
  home.homeDirectory = "/home/leigh";

  # Packages that should be installed to the user profile.
  home.packages = [                               
    pkgs.htop
  ];

  # This value determines the Home Manager release that your
  # configuration is compatible with. This helps avoid breakage
  # when a new Home Manager release introduces backwards
  # incompatible changes.
  #
  # You can update Home Manager without changing this value. See
  # the Home Manager release notes for a list of state version
  # changes in each release.
  home.stateVersion = "22.11";

  # Let Home Manager install and manage itself.
  programs.home-manager.enable = true;

  programs.emacs = {                              
    enable = true;
    extraPackages = epkgs: [
      epkgs.nix-mode
      epkgs.magit
    ];
  };

  services.gpg-agent = {                          
    enable = true;
    defaultCacheTtl = 1800;
    enableSshSupport = true;
  };
}

Thank you for the help. For info, the command I was running was:
nix build .#homeManagerConfigurations.leigh.activationPackage

Which I now realize is not going to call the new configuration info in the flake.nix?

Yep indeed. This is just a normal nixos config now, your home-manager config will be built with the rest of your system if you use nixos-rebuild.

If you want to keep them separate, I’d suggest looking at the standalone setup section here and using the home-manager --flake command.

1 Like