Problems with `flake.nix` and Home Manager

I am trying to get my first NixOS build with flakes and Home Manager.

Here is my relevant flake.nix session:

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

outputs = { nixpkgs, home-manager, hyprland,  ... }@inputs:
  let
    system = "x86_64-linux";
    pkgs = import nixpkgs {
      inherit system;
      config = { allowUnfree = true; };
    };
    lib = nixpkgs.lib;
  in
  {
    nixosConfigurations = {
      framework = lib.nixosSystem {
        inherit system;
	      specialArgs = { inherit inputs; }; # allows access to flake inputs in nixos modules
        modules = [
          ./configuration.nix
          hyprland.homeManagerModules.default
          {wayland.windowManager.hyprland.enable = true;}
          home-manager.nixosModules.home-manager
        ];
      };

	  # Home Manager stuff
    homeManagerConfigurations = {
      storopoli = home-manager.lib.homeManagerConfiguration {
        inherit system pkgs;
        username = "storopoli";
        homeDirectory = "/home/storopoli";
        configuration = {
          imports =[
            ./modules/home-manager/home.nix
            ./modules/home-manager/keyboard.nix
            ./modules/home-manager/variables.nix
            ./modules/home-manager/packages.nix
            ./modules/home-manager/dotfiles.nix
            ./modules/home-manager/vscode.nix
            ];
          };
        };
      };
    };
  };
}

Then my modules/home-manager/home.nix is something like:

{ config, pkgs, ... }:

{
  config = {
    home.stateVersion = "22.11";
  };
}

and for example ./modules/home-manager/variables.nix:

{ config, pkgs, ... }:

{
  config = {
    # Session variables
    home.sessionVariables = {
    MOZ_ENABLE_WAYLAND = 1; # Firefox Wayland
    };
  };
}

I am getting the following error:

error: The option 'home' does not exist. Definition values:
- in /nix/store/<something really big I cant get from my vm>-source/flake.nix:
   {
     _type = "if";
     condition = true;
     content = {
       packages = [
       ...

This is really cryptic I have no idea what to do. Been watching a bunch of videos, and also going over documentation and topics here; but to no avail.

1 Like

Hmm, there are a couple of strange things here, looking at the implementation of the lib.homeManagerConfiguration function in home-manager, you should already get an error because you are not supposed to use the configuration argument, you should instead pass the modules that you want to include in the modules argument. (https://github.com/nix-community/home-manager/blob/1b8bf5c3270386a1b6850bd77d79dbdbaf0d7a7c/flake.nix#L42)

Also, what command are you running when you get this error?

not using either home-manager nor hyprland so this may be a completely wrong guess, but shouldn’t hyprland.homeManagerModules.default go into homeManagerConfigurations instead of nixosConfigurations?

Thanks! I managed to do it without Home Manager. I will try again soon.