Hi everyone,
I’m building a btrfs + impermanence setup, but I’m having trouble ensuring everything is properly set up on reboot by activating the hm config. What’s the best approach: using loginShellInit
or a systemd service? Also, where can I find the activate script that home-manager switch
generates?
In an impermanent setup everything you do not specifically declare to stay or define in a module should be gone after a reboot. Just from reading your question it is really difficult to know which home-manager modules you are actually using and how you are using them. Would you mind sharing your config or explaining a bit more in detail what your are having issues with or missing after a reboot?
I’m sorry if I wasn’t clear.
I’m using the impermanence home-manager module to persist user specific directories. My hm config looks like this :
home.persistence."/persist/home/${user.name}" = {
directories = [
"Downloads"
"Music"
"Pictures"
"Documents"
"Videos"
];
files = [];
allowOther = true;
};
but as home-manager is installed in standalone mode, this config is not activated on reboot and my /home contains nothing.
So I’m looking for a way to activate the hm config on reboot
Thanks for the explanation. I just checked the issues upstream and found out, that apparently automatic mounting is only done when the nixos module of home-manager is used. This is what you find upstream:
Important note: You have to use the home-manager
NixOS
module (in the nixos
directory of home-manager
’s repo) in order for this module to work as intended.
I don’t use a standalone home-manager, but for me I can get to the activation script with something like this:
${nixosConfigurations.hostname.config.home-manager.users.user.home.activationPackage.outPath}/activate
.
I think you probably want to write a simple systemd unit to make sure you’re folders are mounted before any services like syncthing, etc. are started. You can easily find this path by using nix repl
in your config directory with your flake.nix
and in the repl loading your flake with :lf .
. Then you can hopefully interactively find the path you need.
Also checkout this GitHub Issue
Thank you very much for your detailed reply and the time you took!
I gave up on home manager standalone out of despair I would have had to access the activation script from nixos with a symlink somewhere. I saw in some old config the issue you mentioned the reference of /nix/var/nix/profiles/per-user/$USER/home-manager/activate
but I think it doesn’t work like that anymore.
well, at least now impermanence works as expected
The only thing i would have liked to have is a way to rebuild only the home manager config but i don’t think that’s possible
In my experience when you only change stuff in your home manager configuration the time to rebuild an entire nixos configuration isn’t that different from rebuilding just the home configuration. And now you don’t even have to think about what to rebuild, a fresh rebuild will simply update everything and include all your changes all the time!
You are welcome. If yoyu don’t need to coompile something like a GPU driver or … nixos rebuild switch
is actually not that much slower, as @olmokramer mentioned. Then only thing is, that you will get a new entry in you bootloader for every switch you make. But at least your impermance works.
However, you can only build your home-manager configuration like this:
nix build .#nixosConfigurations.<HOSTNAME>.config.home-manager.users.<USER>.home.activationPackage
and then activate it like this:
./result/activate
Hope this helps.