jakehamilton / config

One Nix flake to rule them all.
Other
386 stars 23 forks source link

Claryfying the use of home-manager #16

Open stratosgear opened 11 months ago

stratosgear commented 11 months ago

Do you mind explaining a bit how home-manager is triggered from your setup?

"Usually":

But in your repo just a nixos-rebuild would also trigger the home-manager. I would expect it would at least check the hostname and not trigger it if I build for a different host

At which point is the home-manager triggered? I believe this is a by-product of the snowfall lib, triggering it? I bet if I removed the homes folder I would eliminate the home-manager execution (haven't tried it yet).

A by-product of this "issue" is that I (somehow) managed to get all my zsh to start with a double header of toilet 'Plus Ultra'. Checking the .zshrc I saw that it was sourcing the files twice. No idea how I managed that. Once I removed the zsh and starship configurations from modules/nixos/user the double sourcing got fixed (and back to a single Plus Ultra header in the terminals...

I think you mentioned somewhere that you use case does not involve home-maager too much, as your systems are strictly single user, so maybe this is not a priority for you! But home-manager does make some things easier to configure, so if both could be clearly used this would be great.

This might be similar to #8, especially in regards that home-manager seems to be triggered for ALL hosts.

Once again, thanks.... :)

Dokkae6949 commented 11 months ago

I would also be really interested in the topic on how home manager is supposed to be used. Especially since I see quite a few nixos modules which specify home-manager stuff.. this is a bit confusing because it seems that the nixos modules are used like home modules.

Edit: Another quick example which I'm confused about is why you have some things both in home and nixos modules. Like Git for example.

stratosgear commented 10 months ago

I am no expert and I cannot speak for Jake, so please do not let me confuse you, but I have been playing with the config files and my take so far is this:

Home manager is used strictly as a single user account only, that is why you see the plusultra.home.* invocations in multiple places. They all default to the single user defined in the plusultra.user.name user.

As you mentioned, I would rather not see any home manager invocations while I do my usual nixos-rebuild switch operations that are supposed to be system specific only (and not user/home-manager related). It "might" make sense to merge both system and user operations in a single command, if the systems are strictly single user. But that is not the existing documentation that is out there, and thus our confusion... :)

In regards to setting up git with both nixos and home modules: Setting it up as nixos modules will populate configuration files in the global space (/etc/git/config, I believe) while with home modules they will go to ~/.config/git/config.

Again, I am passing along my understanding so far in case some of this would "click" for you.

I would still want to hear more from Jake though... :)

Nikola-Milovic commented 1 month ago

Where do you handle users? I am using impermanence before snowfall and had to specify users in my configuration.nix to have the passwords working

  23   │   users = {
  24   │     mutableUsers = false;
  25   │
  26   │     users = {
  27   │       root.hashedPassword = "$6$SS1zHvFP7bqY6yqo$g3R63sGjSlt8dAZh.oGznVg90GtSciNJDZU.BXb2SrVi.qHjnfcuiYRzwKdEoFq/gpJm
       │ QOWQ7Gr7ZVELKKXcr.";
  28   │
  29   │       user = {
  30   │         hashedPassword = "$6$lP/WAcHvSHwBHxMn$ou44X10FVP3kHaTrIBSpwZGA0jlf5YSLp2lha9fSeJcOLaw5lvWD9BuH3lyNs3qlASqfe/T
       │ VtDSkpj5PzpWJK1";
  31   │         isNormalUser = true;
  32   │         home = "/home/user";
  33   │         description = "User";
  34   │         extraGroups = ["wheel" "networkmanager" "docker"];
  35   │       };
  36   │     };
  37   │   };

Now I am really puzzled as to where do I setup my users and how to setup them since the user configuration should go in /homes not /systems

YaroKasear commented 1 month ago

Where do you handle users? I am using impermanence before snowfall and had to specify users in my configuration.nix to have the passwords working

  23   │   users = {
  24   │     mutableUsers = false;
  25   │
  26   │     users = {
  27   │       root.hashedPassword = "$6$SS1zHvFP7bqY6yqo$g3R63sGjSlt8dAZh.oGznVg90GtSciNJDZU.BXb2SrVi.qHjnfcuiYRzwKdEoFq/gpJm
       │ QOWQ7Gr7ZVELKKXcr.";
  28   │
  29   │       user = {
  30   │         hashedPassword = "$6$lP/WAcHvSHwBHxMn$ou44X10FVP3kHaTrIBSpwZGA0jlf5YSLp2lha9fSeJcOLaw5lvWD9BuH3lyNs3qlASqfe/T
       │ VtDSkpj5PzpWJK1";
  31   │         isNormalUser = true;
  32   │         home = "/home/user";
  33   │         description = "User";
  34   │         extraGroups = ["wheel" "networkmanager" "docker"];
  35   │       };
  36   │     };
  37   │   };

Now I am really puzzled as to where do I setup my users and how to setup them since the user configuration should go in /homes not /systems

I handle users primarily in two places.

There's a common NixOS module I create that all my systems using my flake enable that creates me on all those systems. It includes the typical groups I use, and I use agenix-rekey to store an encryped hash of the password. This results in all my systems having me up and ready to login immediately after installation.

Then there's the actual home-manager module. I have an entire "user" section of modules plus a common module for everything I'd want no matter what the system is.

The impermanence module provides you with the means to persist any files you need, but using home-manager takes care of maybe 90% of what I need declaratively.

You're welcome to look at my flake for how to use home-manager here.