Misterio77 / nix-config

Personal nixos and home-manager configurations.
https://m7.rs/git/nix-config/
MIT License
719 stars 42 forks source link

Home Manager environment not activating under an impermanence setup #22

Closed musjj closed 11 months ago

musjj commented 11 months ago

I've been studying your impermanence setup (really cool stuff!) while trying things out on a VM, and it's been working well so far for the system part. But I'm having trouble getting home-manager to play well with impermanence. For some reason it's just not activating on startup.

So far my setup is pretty simple (mostly copied from yours):

persistence = {
  "/persist/home/${config.home.username}" = {
    directories = [
      "Documents"
      "Downloads"
      "Pictures"
      "Videos"
    ];
    allowOther = true;
  };
};

But after a reboot my home manager environment is not activated. I need to do the following every time:

nix shell home-manager
mkdir -p ~/.local/state/nix/profiles # required or home-manager will throw an error. why?
home-manager switch --flake /etc/nixos

I mean, I guess it kinda makes sense, since the home directory is cleared every time. But I'm not sure how you're handling this in your config. Tbh, I'm still a bit fuzzy with how home-manager manages the user environments, so I'm not really sure how to about debugging this. Any tips?

musjj commented 11 months ago

I figured it out, you have to use home-manager as a NixOS module for this to work:

https://github.com/Misterio77/nix-starter-configs#use-home-manager-as-a-nixos-module