Home-manager not functional [solved]

Hey all! I just got stared with Nixos. I have a rather minimal install right now. I am trying to get home-manager to work.

I want to use it as a module. I did not add the channel, but tried to install it declaratively through configuration.nix. I followed the manual located here: NixOS module - Home Manager Manual

My problem is that the tarball gets downloaded, the systemd service gets installed and starts. But there is no home-manager command available. Home-manager does not run. And the line in comfiguratoin.nix that is meant to import the home-manager configuration trips nixos-rebuilt and has thus remained commented out so far.

Here are the relevant parts from my configuration.nix:

{ config, lib, pkgs, ... }:

let
  home-manager = builtins.fetchTarball "https://github.com/nix-community/home-manager/archive/release-26.05.tar.gz";
in

{
  imports =
    [
      ./hardware-configuration.nix
      "${home-manager}/nixos"
    ];


  home-manager.users.username = {
    /* The home.stateVersion option does not have a default and must be set */
    home.stateVersion = "26.05";
    /* Here goes the rest of your home-manager config, e.g. home.packages = [ pkgs.foo ]; */
    programs.bash.enable = true;
  };
  #home-manager.users.username = import ./home.nix;
  home-manager.useUserPackages = true;
  home-manager.useGlobalPkgs = true;
  home-manager.backupFileExtension = "backup";

No worries, “username” isn’t my real username, I replaced it before posting.

I created a /etc/nixos/home.nix and a ~/.config/home-manager/home.nix with the same content:

{ config, pkgs, ... }:

{
  home.username = "username";
  home.homeDirectory = "/home/username";
  home.stateVersion = "26.05";
  program.home-manager.enable = true;
  programs.bash = {
    enable = true;
    shellAliases = {
      testhome = "echo home.nix successfully loaded";
    };
    #profileExtra = ''
    #  if [ -z "$WAYLAND_DISPLAY" ] && [ "$XDG_VTNR" = 1 ]; then
    #    exec uwsm start -S hyprland-uwsm.desktop
    #  fi
    #'';
  };
}

When I do ‘sudo nixos-rebuild switch’, I get no errors with the above config as is. I do get an error, if I uncomment the line that imports the home.nix file.

The tarball is downloaded and seems to install just fine. The systemd service is created as well. It stars but becomes inactive.

$ systemctl status "home-manager-username.service"
● home-manager-username.service - Home Manager environment for username
● home-manager-username.service - Home Manager environment for username
     Loaded: loaded (/etc/systemd/system/home-manager-garnix.service; enabled; preset: ignored)
     Active: active (exited) since Sun 2026-09-27 11:22:04 CEST; 33min ago
 Invocation: 5cc2aa199e044cefb83efa3553915777
   Main PID: 11865 (code=exited, status=0/SUCCESS)
         IO: 0B read, 0B written
   Mem peak: 7.2M
        CPU: 317ms

Sep 27 11:22:04 nixos hm-activate-username[11865]: Activating checkFilesChanged
Sep 27 11:22:04 nixos hm-activate-username[11865]: Activating checkLinkTargets
Sep 27 11:22:04 nixos hm-activate-username[11865]: Activating writeBoundary
Sep 27 11:22:04 nixos hm-activate-username[11865]: Activating installPackages
Sep 27 11:22:04 nixos hm-activate-username[11865]: Activating linkGeneration
Sep 27 11:22:04 nixos hm-activate-username[11865]: Cleaning up orphan links from /home/username
Sep 27 11:22:04 nixos hm-activate-username[11865]: Creating home file links in /home/username
Sep 27 11:22:04 nixos hm-activate-username[11865]: Activating onFilesChange
Sep 27 11:22:04 nixos hm-activate-username[11865]: Activating reloadSystemd
Sep 27 11:22:04 nixos systemd[1]: Finished Home Manager environment for username.

However, there is not home-manager command:

$ home-manager switch
bash: home-manager: command not found

If I uncomment the import of home.nix (I’m talking about the line “home-manager.users.garnix = import ./home.nix;”), I get the following:

$ sudo nixos-rebuild switch 
error:
       … while evaluating the attribute 'config'
         at /nix/store/6y3c73nsyz4wl3r4bis42mxpy9b2v01k-nixos-26.05.10620.f5c082a40f75/nixos/lib/modules.nix:402:9:
          401|         options = checked options;
          402|         config = checked (removeAttrs config [ "_module" ]);
             |         ^
          403|         _module = checked (config._module);

       … while calling the 'seq' builtin
         at /nix/store/6y3c73nsyz4wl3r4bis42mxpy9b2v01k-nixos-26.05.10620.f5c082a40f75/nixos/lib/modules.nix:402:18:
          401|         options = checked options;
          402|         config = checked (removeAttrs config [ "_module" ]);
             |                  ^
          403|         _module = checked (config._module);

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: attribute 'home-manager.users.username' already defined at /etc/nixos/configuration.nix:91:3
       at /etc/nixos/configuration.nix:97:3:
           96|   };
           97|   home-manager.users.username = import ./home.nix;
             |   ^
           98|   home-manager.useUserPackages = true;
Command 'nix-build '<nixpkgs/nixos>' --attr config.system.build.nixos-rebuild --no-out-link' returned non-zero exit status 1.

Any ideas?

The NixOS module does not use the home-manager command, instead the configuration is deployed using nixos-rebuild as usual.

The issue is this:

I.e., since you’re defining the setting partially inside configuration.nix, you can’t import settings for it like that as well. Move everything under home-manager.users.username into home.nix. That is, put stateVersion and programs.bash in there as well and delete the block in configuration.nix.

In fact, at second glance, you’ve already partially done that and are currently just duplicating the settings.


Don’t do that. Since you’re not specifying a hash, this will literally update every time nix’ tarball TTL expires, so every hour or so. You have no control over what’s being deployed like this.

You can specify a hash, but I don’t recommend this because I expect newcomers will forget to bump that and/or misunderstand that nix trusts hashes so fail to update correctly.

If you don’t want to use the channel, use npins (which is just a command line tool to do exactly that hash shenanigans I describe) or flakes to manage your dependencies. That’s much saner.

Thank your so much for your help! I removed the entire home-manager.users.username section from configuration.nix and added the line importing the home.nix file back in, so now (besides the tarball fetching and the import line) only the following lines remain:

  home-manager.users.username = import ./home.nix;
  home-manager.useUserPackages = true;
  home-manager.useGlobalPkgs = true;
  home-manager.backupFileExtension = "backup";

nixos-rebuild switch now runs without errors. And the bash alias I defined in home.nix works, proving that home-manager is in fact running perfectly! :slight_smile:

Thank you also for your warning regarding the tarball fetching. I did intend to move to flakes for managing dependencies anyway, but I haven’t gotten into that yet. I am not yet certain I fully understand all the manners in which they can be used. I wanted to first have a working system with home-manager. And I wanted things to be as declarative as possible.

Makes we wonder why the downsides of tarball fetching aren’t mentioned in the manual, though.

Anyway, thanks again! <3

It’s in the nix manual: Built-ins - Nix 2.35.2 Reference Manual

The documentation story is hard – for many people NixOS is their entry-point into the nix ecosystem (hey me too!) even though NixOS by builds on nix and nixpkgs. These both have their own manuals, and I have found many things worth learning by glancing through them.

FWIW, that entry doesn’t say anything about idiomatic use. It’s a reference manual, and therefore lacks the kinds of hints a newcomer would need (like “this is intended for programming use and probably shouldn’t occur in a NixOS config”).

Alas, the nix ecosystem is a big amalgamation of tools. For better or worse, interacting with the community is probably the best way to learn things like this.

Here’s how to use npins for pinning nixpkgs in your config: Automatically managing remote sources with npins — nix.dev documentation

And a similar equivalent for flakes: flake-migration/nixos.md at f45ffffba7018a6614978675eae07ed9135b8125 · eclairevoyant/flake-migration · GitHub

Do note that switching to flakes will impose more restrictions on your config, so the npins route will be more straightforward.