Trying to understand Home Manager

On a single-user system I have a configuration.nix and myuser.nix which is imported to configuration.nix.

I read a lot about Home Manager, and I am wondering if I am missing something by not using it. It seems like I can manage everything using traditional .configs and myuser.nix. Would Home Manager make life easier for me somehow?

1 Like

As you are stating this, I can conclude that you are using NixOS. Right?
If this true, sort answer is no,

But depends, if you are manually configuring something that already has modules in home manager. Then, Maybe.

If you have another machine, without NixOS (in my case a Fedora from my employer), you could share the same settings for your user.

If you are not using NixOS and using some home growth solution to do the same thing that HomeManager does, except for the joy to keep your project, there are less burden by leveraging someone else work :wink:

So I am assuming that your myuser.nix contains basic user settings provided by nixos under users.users.<your-username>*. Other than what’s provided there, NixOS does nothing to manage your user home folder for things like your user shell rc file, etc.

If you want to declaratively manage your user directory (xdg directories, config files, etc) the same way you declaratively manage your NixOS system, then home-manager is your friend.

1 Like

Thanks a lot. I am using NixOS. I have a lot of Linux experience, but am pretty new to NixOS. I might be misunderstanding your second point, but since I haven’t used home manager yet, I doubt anything currently depends on modules from home manager.

So I guess I’ll move past Home Manager and start coming to grips with flakes.

Thank you

Thank you for your reply. What can be defined declaratively with Home Manager that can’t be done in a .nix file?

All files in $HOME. NixOS can often substitute that with system-wide configuration, but that’s not always appropriate.

Examples are systemd user units, ~/.bashrc, neovim config, emacs config, vscode config, email clients, etc.

If you’ve ever been into desktop customization with window managers such as i3, home-manager is godsend for that, NixOS can’t configure most applications used for such setups.

The full list of options lives here: Appendix A. Configuration Options

Some - not all - options have similar counterparts on NixOS, but again, the NixOS options are system-wide. You probably don’t want your bashrc to apply system-wide, as it’s in charge of setting up your user configuration. Not as bad on single-user computers, but your root account and other random system users will be affected.

So I haven’t needed it because it’s a single user system I guess. I’ll check out the configuration options you mentioned to see if there’s anything useful to me.

It sounds like I should go ahead and learn more about it anyway before moving on to flakes.

Thanks

Get BlueMail for Android