Can't Install Home Manager

Can’t Install Home Manager

Per the Home Manager manual, I am trying to install the Home Manager NixOS module. Since I’m following the nixos-24.11 channel, I ran the following:

$ sudo nix-channel --add https://github.com/nix-community/home-manager/archive/release-24.11.tar.gz home-manager
$ sudo nix-channel --update
$ sudo nix-channel --list
home-manager https://github.com/nix-community/home-manager/archive/release-24.11.tar.gz
nixos https://nixos.org/channels/nixos-24.11

I also have the following at the top of my /etc/nixos/configuration.nix file:

{ config, pkgs, ... }:

{
  imports =
    [ # Include the results of the hardware scan.
      ./hardware-configuration.nix
      <home-manager/nixos>
    ];
...

But even after running sudo nixos-rebuild switch, I don’t see a new NixOS option called home-manager.users in my configuration.nix file and I also get the following:

$ systemctl status "home-manager-$USER.service"
Unit home-manager-samir.service could not be found.

Any suggestions as to what I am doing wrong?

Thanks in advance
Samir

Um, yeah, you need to write that yourself. When the manual says it “will introduce” it means nix won’t complain that that option doesn’t exist if you set it. The service also won’t exist until you do.

Thanks. I still cannot get the system to generate the ~/.config/home-manager/home.nix file nor do I have the home-manager executable available.

I put the following configuration in my /etc/nixos/configuration.nix file:

  imports =
    [ # Include the results of the hardware scan.
      ./hardware-configuration.nix
      <home-manager/nixos>
    ];
...
  users.users.samir = {
    isNormalUser = true;
    description = "samir";
    extraGroups = [ "networkmanager" "wheel" ];
    packages = with pkgs; [
    ];
  };

  # Home Manager Configuration
  home-manager.users.samir = { pkgs, ... }: {
    home.packages = [ pkgs.atool pkgs.httpie ];
    programs.bash.enable = true;
  
    home.stateVersion = "24.11";
  };

I then ran sudo nixos-rebuild switch and can see the following:

$ systemctl status "home-manager-$USER.service"
○ home-manager-samir.service - Home Manager environment for samir
     Loaded: loaded (/etc/systemd/system/home-manager-samir.service; enabled; preset: ignored)
     Active: inactive (dead) since Fri 2025-02-07 17:42:21 EST; 1min 19s ago
 Invocation: 8cafde8edaca4daab37481681e2b1a5b
    Process: 10994 ExecStart=/nix/store/kpmqz26d4f1gy99xm3kcr13k1kqdqsd0-hm-setup-env /nix/store/g7gjrx4gbmm4br6yjd16zc5lmvxg3qyr-home-manager-generation (code=exited,>
   Main PID: 10994 (code=exited, status=0/SUCCESS)
         IP: 0B in, 0B out
         IO: 32K read, 0B written
   Mem peak: 6.3M
        CPU: 275ms

Feb 07 17:42:21 nixos hm-activate-samir[11024]: replacing old 'home-manager-path'
Feb 07 17:42:21 nixos hm-activate-samir[11024]: installing 'home-manager-path'
Feb 07 17:42:21 nixos hm-activate-samir[10994]: Activating linkGeneration
Feb 07 17:42:21 nixos hm-activate-samir[10994]: Cleaning up orphan links from /home/samir
Feb 07 17:42:21 nixos hm-activate-samir[10994]: No change so reusing latest profile generation 1
Feb 07 17:42:21 nixos hm-activate-samir[10994]: Creating home file links in /home/samir
Feb 07 17:42:21 nixos hm-activate-samir[10994]: Activating onFilesChange
Feb 07 17:42:21 nixos hm-activate-samir[10994]: Activating reloadSystemd
Feb 07 17:42:21 nixos systemd[1]: home-manager-samir.service: Deactivated successfully.
Feb 07 17:42:21 nixos systemd[1]: Finished Home Manager environment for samir.

$ home-manager
The program 'home-manager' is not in your PATH. You can make it available in an
ephemeral shell by typing:
  nix-shell -p home-manager

I wasn’t sure if I have to manually generate the ~/.config/home-manager/home.nix file myself or not or whether I should just install Home Manager as a package:

  environment.systemPackages = [
    pkgs.home-manager
  ];

Sorry for all the questions. :frowning:

I’m wondering if, because I am installing Home Manager as a NixOS Module (by adding the configuration to my /etc/nixos/configuration.nix file), that’s all I need to do. Because I’m not installing it “stand alone”, I’m not going to have a home-manager command nor will I have a separate ~/.config/home-manager/home.nix file.

I just need to configure Home Manager directly in configuration.nix, correct?

To test this out, I added htop to my home-managers.users.samir section of the file.

I also added a new user, alice, without Home Manager configured.

User samir can access htop but alice cannot.

Yes, exactly, you figured it out :slight_smile:

1 Like