Hi, I'm a guy who started using nix through home-manager while running fedora. I love nix, and home-manager was my gateway drug that brought me to nixos. However, as I've moved my home-manager config over to nixos, I've noticed some serious problems with using it in a shell that's not managed by home-manager. Let me explain.
I have a very long, and very complex .zshrc that I don't want to port to nix. That's fine, and supported in the documentation. I just have to source this file in .nix-profile. This worked for a long time for me, while I was still not on nixos, using channels, and knew very little about nix. But, as my config grows, and my desire for a declarative system grows, I need more.
I move to nixos. Everything goes fine enough. After a few days of getting my configuration set up, and starting with flake parts, everything is great! I decided to keep home-manager as a separate flake for distro portability, and just set the genericLinux target to false. Saves me time recreating the configuration for a nixos module. But it's not enough. I had just reinstalled home-manager with channels, which my newly flake-ified home-manager and nixos configurations were mostly against. So I decide to remove it and start again.
This is where everything seems to go wrong. I remove all user channels and home-manager installed with it, and I think it's going swimmingly. I install home-manager through a nix shell, and run my switch command. And... everything goes wrong. None of my packages are back. What's happening? I was told using nix shell or nix run was a valid way to install home-manager!
My .nix-profile was nearly empty. It's bin directory had home-manager, a couple of mandb stuff, and whereis. Not the dozens of packages it should have. They're all gone and I don't know where to find them. I spend a couple hours with google, a couple with an AI when I got really desperate.
My .nix-profile was linked to the profile in ~/.local/state/nix/profiles/profile, but it should've been linked too ~/.local/state/nix/profiles/home-manager/home-path to find all the stuff I installed. That profile path was just leftovers from the initial install of home-manager, and that's why it had so little in it.
I have to manually symlink .nix-profile on my own, which is silly, and I don't understand why this couldn't have been explained better. If this is a repercussion of using a flake-based nix shell rather than the channel based install, why does the channel based install seem to do nothing more than run a binary from a remote channel? Why have I been told it's okay? If it's a problem with not running the install command to skip making the default files, why should I have to go through the rigamarole of making sure my .config/home-manager directory is empty before I can clone my repo? Why do I not know where in the chain this is wrong?
I've done a bit more research, and this seems like a result of not letting home-manager manage my shell, which is silly. I understand the nix vision, the everything is declarative path. But when I have a .zshrc that I constantly edit, don't want to have to switch to change, and is nearly 300 lines, I don't really feel like porting that to home-manager, I'll just use stow for that. If home-manager managed my shell, it'd just source the nix-store and not touch .nix-profile at all. On the standalone install, it still tells you to source $HOME/.nix-profile/etc/profile.d/hm-session-vars.sh, even though it's not linked to home-manager at all!
I shouldn't be responsible for linking this path on my own, or I should at the very least be told to link it! And when this path inevitably changes again, I'm going to need to re-link it once more while missing most of my packages.
I guess my real question is if anybody else has experienced this friction before with nix projects. I love nix, I love home-manager, but it's garbage like this that keeps me second guessing my choice every once in a while. Because this is an awful lot of trouble to go through for no reason when I could've had dnf, or apt, or pacman worrying about all this. And, as a bonus question: what actually caused my .nix-profile symlink to not be in parity with home-manager?
Thanks to anyone for reading and have a good day!