Home manager not found at store

I recently added unstable version to my configurations and after that i was facing the same issue in the configuration file.

Now im trying to add git config in a declarative way. and now im facing the same issue

❯ home-manager switch --flake .#system
Home Manager not found at /nix/store/9613fxrf433y10fz18ccixj4zpmdibzq-source.
error: flake 'path:/home/mainuser/.dotfiles' does not provide attribute 'packages.x86_64-linux.homeConfigurations."system".activationPackage', 'legacyPackages.x86_64-linux.homeConfigurations."system".activationPackage' or 'homeConfigurations."system".activationPackage'

this is my home.nix

{ config, pkgs, systemSettings, userSettings,... }:
{
    imports = [
    ./sh/sh.nix
  ];

  #home.username = "mainuser";
  home.username = userSettings.username;
  #home.homeDirectory = "/home/mainuser";
  home.homeDirectory = "/home/${userSettings.username}";
  programs.git = {
    enable = true;
    userName = "";
    userEmail = "";
  };

  home.stateVersion = "23.05"; # Please read the comment before changing.
  home.packages = with pkgs; [
    hello
    emacs
    tmux
    htop
  ];

  home.file = {
  };

I also keep seeing this as a temporary solution.

Questions:

  1. Am i using the command correctly ?
    is it home-manager switch --flake .#system or home-manager switch --flake .
  2. and am i making any mistake in the .nix files ?
  3. If i need to use the home-managers branch as a temp solution. how should i do it ?

Isn’t clear if you’re using home-manager stand alone (without NixOS) or home-manager with NixOS.

Your previous issue was with NixOS, in this case:

  1. You using wrong command, should be nixos-rebuild switch instead
  2. Not sure becuse of 1
  3. Change you input flakes home-manager.url = "github:nix-community/home-manager/{BRANCH_NAME}";

If you are not using it stand alone:

  1. Not sure because o 2
  2. We need to know your flake.nix
  3. Change you input flakes home-manager.url = "github:nix-community/home-manager/{BRANCH_NAME}";

Sorry for not being clear. I am using home-manager with NixOS.

Correct me if im wrong please. My understanding was,

when we make system level changes (config.nix), command to accept the changes should be sudo nixos-rebuild switch --flake . (in my case its sudo nixos-rebuild switch --flake .#system, which i recently understood this too)

And when we make changes on user level (home.nix), then command to accept these changes should be home-manager switch --flake . or home-manager switch --flake .

Am i correct ?!

Yes or not.

You have two tools.

One, home-manager that configure your user.
Other, NixOS that configure your system and your user.

home-manager can be used alone in any system (including NixOS) or “as NixOS plugin” (‘module’ is term but plug-in denote what it means).

Your flake from the other post (and the ‘system’ in your command), seems like you are trying to use it as plug-in.

In this case you are better running nixos-rebuild.

You could do both, but you’ll end with two home manager fighting (may work because the source be the same).

If you want to use it alone you have to change your flake to export your home-manager as another output like homeConfigurations.USERNAME. home-manager/templates/standalone/flake.nix at 0dd1c1495af6e6424695670343236f0053bf4947 · nix-community/home-manager · GitHub

so:

home-manager alone (also works in NixOS):

  • command: home-manager switch --flake .
  • flake output: homeConfiguration.USERNAME = home-manager.lib.homeManagerConfiguration...
  • nixos configuration: environment.systemPackages = [ pkgs.home-manager ];
    • isn’t a requirement since you can run directly from with nix run github:nix-community/home-manager -- --flake .

home-manager as NixOS plugin:

  • command: nixos-rebuild switch --flake .
  • flake output: nixosConfigurations.HOSTNAME = lib.nixosSystem...
  • nixos configuration: imports = [ home-manager.nixosModules.home-manager ]; or similar

Correct me if understood the right way.

Stand-alone → for one machine, where its dedicated to a single user.
Module/plugin → is for multi user, one a same machine

home-manager → manages the dotfiles for user through home.nix.

And when Flakes is involved → it takes control over both system config (configuration.nix) and user config (home.nix).

And I have messed up my setup by Some how without much knowledge by initially having a stand-alone setup and later i ended up using the plugin way. And now to get back to stand-alone way i need to remove the nixosConfigurations from my flakes.nix and retain the rest like below ? is that what you mean to say ?

{
  description = "Initial Flake - standalone";

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

-    home-manager.url = "github:nix-community/home-manager/release-23.11";
+    home-manager.url = "https://github.com/Kareem-Medhat/home-manager";
    home-manager.inputs.nixpkgs.follows = "nixpkgs";
  };

  outputs = { self, nixpkgs, nixpkgs-unstable, home-manager, ... }:
    let
      systemSettings = {
        system = "x86_64-linux";
        hostname = "nixos";
      };
      userSettings = {
        username = "mainuser";
        dotfilesDir = "~/.dotfiles";
      };

      system = systemSettings.system;
      lib = nixpkgs.lib;
      pkgs = nixpkgs.legacyPackages.${systemSettings.system};
      pkgs-unstable = nixpkgs-unstable.legacyPackages.${systemSettings.system};

    in {
-    nixosConfigurations = {
-      system = lib.nixosSystem {
-        system = systemSettings.system;
-        modules = [ ./configuration.nix ];
-        specialArgs = {
-          inherit systemSettings;
-          inherit userSettings;
-          inherit pkgs-unstable;
-        };
-      };
-    };
+    homeConfigurations = {
+      userSettings.username = home-manager.lib.homeManagerConfiguration {
+        inherit pkgs;
+        modules = [ ./home.nix ];
+        extraSpecialArgs = {
+          inherit systemSettings;
+          inherit userSettings;
+          inherit pkgs-unstable;
+        };
+      };
+    };
  };
}

On home.nix i can keep the same as i have in the OP.
And in configuration.nix,

{ config, pkgs, pkgs-unstable, systemSettings, userSettings, ... }:

{
  imports =
    [ ./hardware-configuration.nix ];

  # Bootloader.
  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;

  # Session Variables
  environment.sessionVariables = {
    FLAKE = "/home/${userSettings.username}/.dotfiles";
  };

  networking.hostName = systemSettings.hostname;

  # Flakes
  nix.settings.experimental-features = [ "nix-command" "flakes" ];

  # Define a user account. Don't forget to set a password with ‘passwd’.
  users.users.${userSettings.username} = {
    isNormalUser = true;
    description = userSettings.username;
    extraGroups = [ "networkmanager" "wheel" ];
    packages = with pkgs; [
      firefox
      kate
    ];
  };

  nixpkgs.config.allowUnfree = true;

  environment.systemPackages =
  (with pkgs; [
    ...
    home-manager
    ...
  ])
  ++
  (with pkgs-unstable; [
    ...
  ]);

  system.stateVersion = "23.05"; # Did you read the comment?
}

If yes, then in this video he uses both homeConfigurations and nixosConfigurations. Whats the differences between them ?

And, sorry im not getting this part

Standalone means that it’s not done as part of the NixOS-system but separately, usually managed through the home-manager command. You can modify the home-manager config of a user without rebuilding your whole system. This is also what you use when you want to use home-manager for users on systems that are not NixOS itself.

Module/Plugin means that home-manager is built and deployed as part of the NixOS-system itself. So you are NOT using the home-manager command but home-manager is built and deployed as part of the usual nixos-rebuild build/switch process. So to change the home-manager config of a user will require you to do a full system update with creating a new generation.

Generally, using standalone gives you more freedoms. You can update and rollback the system and user configs individually. However, if you just want to update everything, standalone is a longer process since you need to update the system and your users home configs individually.

On my personal NixOS systems I prefer the Module mode. Once everything is set up the way I like it, I rarely feel the need to update my home-manager config. And with proper modularization it is easy to use the same home-manager config in Module and Standalone mode, e.g., when I want to deploy my home-config to a Non-NixOS system.

1 Like

Thats way more clear now.Thanks a lot for taking your time to explain me the core of it.

So home-manager, manages or in a way manages all our dotfiles. and it creates/generates symlinks of our dotfiles and keeps them in the nix-store.
using home-manager we can define our system either as a Stand-alone or as a Modular.

If its stand-alone, it manages the dotfiles of the user, and the user level configs have a freedom, and will be controlled through home-manager <switch/rebuild> commands.
If its Modular, still the same, user level configs will be controlled by home-manager, but through the usual nixos-rebuild <switch/rebuild> command. (we as a user would not or wont have the need to use home-manager commands).

Home Manager not found at /nix/store/9613fxrf433y10fz18ccixj4zpmdibzq-source.
error: flake 'path:/home/mainuser/.dotfiles' does not provide attribute 'packages.x86_64-linux.homeConfigurations."system".activationPackage', 'legacyPackages.x86_64-linux.homeConfigurations."system".activationPackage' or 'homeConfigurations."system".activationPackage'

So the above error that im getting, is may or may not be due to this fact(me having configured my home-manager as module and still using the home-manager cmds,) right ?!

Yes, understood.

understood. But can i know what is that “rarely” scenario.

So if i would like to do the same, and to concise the whole discussion, i dont need to make changes to my flake.nix or home/configuration.nix either right. Just changing the home-manager the branch in the flake.nix and going further just nixos-rebuild will be my work/command flow that i need ti follow. correct ?!

Some of the things I remember in the past months:

  • Add fzf completion to lots of locations
  • I discover a new command line tool and want it absolutely everywhere now (e.g. ripgrep)
  • Change my zsh config to powerlevel10k
  • Synchronize a wine-environment so that yabridge-powered virtual instruments are available on all machines that I use to make music (home-manager config needed just for yabridge.toml distribution)

I don’t know, I’m not much of a ricer once things work to a satisfactory level.

Do you have your current configuration somewhere as a git repo? Generally, if you want to go modular, you do three things:

  • Add the home-manager module to your NixOS config, e.g. (assuming you named the flake-input home-manager),
system = nixpkgs.lib.nixosSystem {
    ...
    modules = [
    ...
    home-manager.nixosModules.home-manager
    ...
    ];
};
  • Also under modules, you can do some global configuration that will apply to all users (taken from my config, adapt for you):
modules = [
    ...
    {
        home-manager.useGlobalPkgs = true;
        home-manager.useUserPackages = true;
        home-manager.sharedModules = [ 
            ./hmmodules 
            "${vscode-server}/modules/vscode-server/home.nix"
            nix-index-db.hmModules.nix-index
        ];
        home-manager.extraSpecialArgs = { inherit aww self audio; };        
    }
];
  • And finally, still in the same modules section, you define the user modules:
modules = [
...
{
    home-manager.users.user1 = import ./users/user1.nix;
}

Note that in ./users/user1.nix you are now in the context of home-manager modules, not NixOS-modules anymore. So the stuff you find on search.nixos.org under the modules search is not going to work there. Instead, you can use stuff from Appendix A. Home Manager Configuration Options now.

You can check out my config, but it’s gotten a bit convoluted over time and is probably more compartmentalized than you will need for a single system. I define a nixosSystem' function here that has all the settings that all my systems shall have in common, and there’s some home-manager stuff in there. A system with two users is then defined here.

Firstly, im extremely sorry for the late reply.

This is what i was trying to setup (add my git username declaratively), so was trying to add them under my home.nix. After adding the programs.git to the home.nix i gave the wrong command as home-manager rebuild instead of nixos-rebuild. then this OP.
so to answer you question, No. its not in git and im kind of stuck way before pushing them, So sorry for the inconvenience. I looked at the example what you have given and im unable to correlate with my existing .nix files. So im adding them here for a ref, (as of now this is the current state all the .nix files and i would like to go modular like they way you do)
flake.nix

{
  description = "Initial Flake";

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

    # home-manager.url = "github:nix-community/home-manager/release-23.11";
    home-manager.url = "https://github.com/Kareem-Medhat/home-manager";
    home-manager.inputs.nixpkgs.follows = "nixpkgs";
  };

  outputs = { self, nixpkgs, nixpkgs-unstable, home-manager, ... }:
    let
      systemSettings = {
        system = "x86_64-linux";
        hostname = "nixos";
      };
      userSettings = {
        username = "mainuser";
        dotfilesDir = "~/.dotfiles";
      };

      system = systemSettings.system;
      lib = nixpkgs.lib;
      pkgs = nixpkgs.legacyPackages.${systemSettings.system};
      pkgs-unstable = nixpkgs-unstable.legacyPackages.${systemSettings.system};

    in {
    nixosConfigurations = {
      system = lib.nixosSystem {
        system = systemSettings.system;
        modules = [ ./configuration.nix ];
        specialArgs = {
          inherit systemSettings;
          inherit userSettings;
          inherit pkgs-unstable;
        };
      };
    };
    homeConfigurations = {
      userSettings.username = home-manager.lib.homeManagerConfiguration {
        inherit pkgs;
        modules = [ ./home.nix ];
        extraSpecialArgs = {
          inherit systemSettings;
          inherit userSettings;
          inherit pkgs-unstable;
        };
      };
    };
  };
}

my configuration.nix is,

{ config, pkgs, pkgs-unstable, systemSettings, userSettings, ... }:

{
  imports =
    [ ./hardware-configuration.nix ];

  # Bootloader.
  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;

  # Session Variables
  environment.sessionVariables = {
    FLAKE = "/home/${userSettings.username}/.dotfiles";
  };

  networking.hostName = systemSettings.hostname;

  # Flakes
  nix.settings.experimental-features = [ "nix-command" "flakes" ];

  users.users.${userSettings.username} = {
    isNormalUser = true;
    description = userSettings.username;
    extraGroups = [ "networkmanager" "wheel" ];
    packages = with pkgs; [
      firefox
      kate
    ];
  };

  nixpkgs.config.allowUnfree = true;

  environment.systemPackages =
  (with pkgs; [
    ...
    home-manager
    ...
  ])
  ++
  (with pkgs-unstable; [
    ...
  ]);

  system.stateVersion = "23.05"; # Did you read the comment?
}

And my home.nix is

{ config, pkgs, systemSettings, userSettings,... }:
{
    imports = [
    ./sh/sh.nix
  ];

  #home.username = "mainuser";
  home.username = userSettings.username;
  #home.homeDirectory = "/home/mainuser";
  home.homeDirectory = "/home/${userSettings.username}";
  programs.git = {
    enable = true;
    userName = "";
    userEmail = "";
  };

  home.stateVersion = "23.05";
  home.packages = with pkgs; [
    hello
    emacs
    tmux
    htop
  ];

  home.file = {
  };

im extremely sorry if im asking for more. Im still a beginner and unable to understand atleast bare minimal things from your .nix. to me it looks way too complex. :slightly_frowning_face:

Something like this probably:

    nixosConfigurations = {
      system = lib.nixosSystem {
        system = systemSettings.system;
        modules = [ 
            ./configuration.nix
            home-manager.nixosModules.home-manager
            {
                home-manager.users.${userSettings.username} = import ./home.nix;
                home-manager.extraSpecialArgs = { inherit systemSettings userSettings pkgs-unstable; };
            }
        ];
        specialArgs = {
          inherit systemSettings;
          inherit userSettings;
          inherit pkgs-unstable;
        };
      };
    };
1 Like

thank you verrrrrry much :handshake: @polygon. I tested the change by adding some random packages into home and removing them. It worked.

So let me concise my workflow/command flow going further, correct me if im wrong.
Going further (after adding hom-manager.nixosModules. to the nixosConfigurations)

  1. im officially using the module way of using the home-manager.
  2. nixos-rebuild will be taking care of the home-manager changes (dont need to use home-manager cmds until and unless some rarely situations - which i might face in future to figure it out)

right ?

Its really hard to understand from any repo’s .nix files as a beginner. And the documentation make me forget everything. And comparing multiple persons .nix files makes the understanding way worse. Im glad to receive your .nix’s. Will clone yours locally and inspect the way you have built it from the beginning. may be by that way i might get better understanding. Please do share you thoughts if there is a better way to understand the structuring or configuring our own .nix’s.

1 Like

Glad I could help. Yes, the way I showed is using home-manager as a module, so you will use nixos-rebuild for everything. You also don’t need the whole homeConfigurations-block that you have. However, you can still keep it around in case you want to deploy just home-manager to, e.g., a Non-NixOS machine. You basically did it correctly there already, put all the actual config in a home.nix, nicely divided from the nixosSystem respectively homeManagerConfiguration so you can potentially use both.

If you want to look at my config, there should be a state after I transitioned to Flakes where it’s just a single system and might be a somewhat good blueprint. If you look at any of the later versions where I added my home-server, I just want to add that I started my Flake using the flake-utils-plus library. However, I transitioned away from it to bare flakes (basically what you have now) once I hit a few limitations that I could not overcome. I never bothered to fully remove it from my config, though. So if some parts in the top-level flake.nix don’t make immediate sense, it’s not because of some cleverness from my side, but because I’m too lazy to clean up.

1 Like

understood.
I was feeling down for not getting a clear picture of the workflow but everyone writing their nix files like a :cake: .
thanks a lot for your help, heads-up and advice :vulcan_salute: :smiley: