nix-community / impermanence

Modules to help you handle persistent state on systems with ephemeral root storage [maintainer=@talyz]
MIT License
1.01k stars 76 forks source link

Cannot use `users.users` without infinite recursion #179

Open MattSturgeon opened 3 months ago

MattSturgeon commented 3 months ago

I'd like to configure persistent directories for all normal users.

I figured a filterAttrs and mapAttrs would do the trick, however it seems environment.persistence.*.users modifies users.users in some way resulting in infinite recursion.

environment.persistance."/persist".users =
  mapAttrs
  (name: {
    directories = {
      # Defaults for all normal users
    };
  })
  (filterAttrs (name: user: user.isNormalUser) config.users.users);

I guess this the same underlying issue that means environment.persistence.*.users.home can't default to users.users.*.home? Although I'm unsure why that doesn't also apply to users.users.*.group...

It'd be great if either the recursion issue could be somehow fixed, or at least better documented. Alternatively providing an "allNormalUsers" option (terrible name, I know) that is equivalent to doing this, but somehow bypassing recursion issues, would also resolve this.