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.
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.
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:
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.