Install Packages
There's two ways to install packages using home-manager.
home.packages
: for any package exists in a channel.programs.<pkg_name>
: for build in options for certain package by home-manager.
Install from a channel
home.packages
provides a explicit way to include what package should be installed. pkgs
here is a channel unpacked from theflake.nix
.
{ config, pkgs, ... }: {
home.packages = with pkgs; [
git # package names came from channel
neovim
ripgrep
openssh
lazygit
];
}
2
3
4
5
6
7
8
9
NOTE
pkgs
is the unique attribute in the function of home.nix
, it should be always available.
TIP
How do I know the package name? Search on NixOS Search to find the package you want.
Install by builtin option
For some packages, home-manager provides builtin options to set them up. It seems pkgs
is not involved, actually it was used by default for programs.<pkg_name>
. So we should always make sure pkgs
exists as a parameter for the function in home.nix
, should be discussed later.
{ config, pkgs, ... }: {
programs.git.enable = true;
}
2
3
enable
implies that the package will be installed implicitly.
Use another channel
Home-manager options also provides a package
attribute for not using default pkgs
.
programs.git = {
enable = true;
package = unstable.git;
};
2
3
4
NOTE
unstable
here should be another channel imported as one of the attribute of the function parameter. We'll discuss how to use multiple channels in later chapter.
INFO
Only few packages has builtin options, how do I know what attribute I can set? Check out Home-manager Options and search programs.<pkg_name>