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?