I’m trying to understand the interplay of nixos and home manager, and I’m not sure if I understood the various things that home manager offers.
From what I understand, the 2 big things are the ability to install local, user specific packages, and the ability to define the dotfiles in nix.
But supposing I am a situation where I only have one user on my machines and I don’t care about packages being installed globally, and I already have a set of dotfiles in their respective native formats that I don’t want to migrate, just reference, then do I need home manager? Will I lose something else if I do away with it?
I’m not against using it of course, but I prefer to understand the why beforehand
(As a bonus question, the code for my nixos configurations was made by beginner me and is 4 years old, so I’m sure parts of it are either bad practice or outdated, so I’d be happy for any criticism!)
But I also have a long-term suspicion that there is a misunderstanding of Home Manager, especially by newcomers who see it used (and recommended?) a lot, viewed as “symlinking dotfiles with extra steps”.
The added value is modules, just as in NixOS. Yes, there are many modules which are just an enable option and a freeform settings that gets transformed to the target format. I suggest instead looking at the email module (Appendix A. Home Manager Configuration Options), which provides a centralized definition of accounts, which other email-related tools can automatically consume to properly configure themselves. For my particular setup (with mbsync, imapnotify, mu, and mstmp; and about 8 email addresses), this greatly reduces the effort and complexity of wiring up all the tools with all the accounts, as well as reduces risks of configuration errors. When adding a new account, I do not have to think about all the files where I need to add new configuration; instead, I just add a new account and the rest “just works”.
Metaprogramming with nix is also useful. Being able to use variables and substitute different values on different machines is practically the entire reason I started using nix. It’s hard to e.g. globally share a set of color variables between dozens of applications otherwise.
But yeah, if you don’t:
Care for using nix to share globals between dotfile templates
Want to deploy your dotfiles alongside the exact software versions they’re intended for
Want to replicate your configuration across many machines, at least some of which are not NixOS
Need to create files in your home directory with nix for any other reason
I can totally see home-manager seeming pretty useless!
In fairness, I think people who use ye olde emacs/vim and other software that can take similar amounts of effort to maintain are probably much more in tune with the need for something like home-manager. If you use vscode (and aren’t a power user of it) and otherwise stick to mostly GNOME you probably don’t need home-manager.
I would never dare argue with Tlater, but most of what HM does is convenience isn’t it? It is a necessity if you have multiple users on a system, or if you run other Linux variants. [Perhaps it should be called Away Manager?] Personally I found it gunked up my system so I retired it.
Depends on what you consider “convenience”, and what kind of software you use. There are situations in which you need to create files in $HOME; Even if you’re fine with blending user separation like that, not all software is amenable to system-wide configuration.
FWIW I do intend to move to custom modules with hejm and a wrapper-oriented config one day, as I do think home-manager does have its issues (and the modules are generally very low quality), but at the moment it does solve genuine problems for me that aren’t possible with just NixOS.
@TLATER that’s an interesting point of view, though I come from the opposite side: it’s because I spent a lot of time tuning my dotfiles, vim config and others that I want to keep managing them in a native way, not only to keep in my prior time investment, but also because I found that 3rd party abstractions always hinder me by having their own opinion of what is and isn’t an important option. It’s more “I already invested into nix-agnostic solutions” than “these problems don’t apply to me”, hence my interrogation whether I was sure home-manager actually addressed the problem I thought it did and not something else
I migrated from very carefully managed native config to nix after a decade and a half if doing that
I appreciate the perspective, and was skeptical at first too - in fact, my dotfiles are still largely native, see e.g. my emacs dotfiles.
Using home-manager to manage the installation and composition of dependencies is still very helpful in this case. E.g. managing tree-sitter binaries with nix works way more predictably, especially between machines.
It wasn’t until I fully embraced and learned how all of it works that I realized how useful it is.
The biggest value I’ve found for Home Manager, and the reason I still use it, is for user services. Both the built-in ones, like services.swayidle, and custom ones in systemd.user.services. Moving those to the NixOS system config would be daunting to figure out.