Official installation instructions can be found in the NixOS Wiki or the Home Manager community docs.
I deploy my HM configuration as a flake which needs be enabled.
For standalone personal computers, I enable this via a nixos
option nix.settings.experimental-features = [ "nix-command" "flakes" ];
.
If running Home Manager on top of another distro, I enable this
via a nix config file:
# ~/.config/nix/nix.conf
experimental-features = nix-command flakes
Nix Flakes documentation if needed.
To rebuild home manager, run the command home-manager switch --flake /path/to/flake/#<flake_profile>
where flake_profile
is
whatever gets set in flake.nix. I define the following
alias for convenience:
home.shellAliases = {
hms = "home-manager switch --flake $XDG_CONFIG_HOME/home-manager/#$USER";
}
One advantage of home manager as a flake is pinned dependencies for reproducibility (flake.lock).
In practice, this means the nix channel I follow gets pinned and
thus all packages I download and install are the same across
all machines I use. To upgrade all system packages, I run the
command nix flake update
, rebuild home manager, and then
commit my new lockfile.