Difference between nix profiles and home-manager

I’m trying to understand conceptually the preferred approach to do things in NixOS. I have a question regarding the philosophy between nix-profile and home-manager.

If Nix Profile is a way to have different environment per user, or can be used for that purpose (quoting the documentation below)

“Profiles and user environments are Nix’s mechanism for implementing the ability to allow different users to have different configurations”

I wonder if I need home-manager at all, or what I would miss if not having it. I know that technically, home-manager manages config per user, whereas a profile is a system wide environment but if I consider individual system wide environment per user, are there some cases where I need to override the system wide environment through a local config and hence, have home-manager?

I am using home-manager at the moment and like it, but just wondering if I actually need it (I’m a beginner in NixOS).

4 Likes

home-manager will generate configs in your $HOME which nix-env doesn’t. So it works better with apps (no need to wrap them with a specific config).

1 Like

@teto Do you have an example where a config in $HOME works better than a global config? Is it specific to certain apps?

2 Likes

While home-manager shares the capability of NixOS to configure user environments, the main difference is that it is platform-independent and works anywhere you have nix. Yes, you can in principle do the same things from your NixOS configuration, assuming your user is also the system administrator. I apply my home-manager setup on both NixOS/Linux and macOS/Darwin, which decouples my systems from my userspace tools. In theory I could live in a shared environment without root permissions without any loss.

2 Likes

If I conclude that this schism between system wide config & user config brings about unwarranted cognitive overhead, do I have an option to tap into home-manager added value while materializing that added value in plain nix profiles? I have never had the need to work in a shared environment.

2 Likes

I am not 100% sure what you are asking, but home-manager actually uses profiles. It installs the built configuration into the user’s profile:

If you do not want separate NixOS and home-manager configuration, yous can use home-manager as a NixOS module.

1 Like

Hm, I see…

Docs say something vague of this becoming the default in future versions.