Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support shared home-manager configurations between all users #594

Closed
vlaci opened this issue Feb 25, 2019 · 7 comments
Closed

Support shared home-manager configurations between all users #594

vlaci opened this issue Feb 25, 2019 · 7 comments

Comments

@vlaci
Copy link

vlaci commented Feb 25, 2019

#549 is broke my configuration. I have created a NixOS module where I can declare a "shared" home manager configuration which is applied to all users managed by nix. I use this approach to generate homogeneous user environments.

The above mentioned change introduces infinite recursion because now home-manager writes the users.users attribute.

I can work around this problem but I thought that it worth to mention this use case [1]


[1] Upon writing the issue description I remembered this xkcd comic https://xkcd.com/1172/

@kalbasit
Copy link
Collaborator

I use something very similar to you, by assigning one home-manager config to multiple users, and this has not broken my setup. Perhaps it's something specific to you? Can you point out how it's setup on your side?

Here's how it's setup on my side:

[1] Upon writing the issue description I remembered this xkcd comic https://xkcd.com/1172/

I love it 🤣!

@vlaci
Copy link
Author

vlaci commented Feb 25, 2019

Your configuration gave me the original inspiration for my version. The difference is that I use users.users directly instead of a separate users attribute set hence the recursion.

@kalbasit
Copy link
Collaborator

@vlaci oh I see, makes sense. @rycee thoughts on how to avoid the infinite loop here?

@rycee
Copy link
Member

rycee commented Feb 25, 2019

Ah, this was unfortunate! I think to fix it one would have to change
https://github.com/rycee/home-manager/blob/f07510e2b63075a5e334e603f666c5c5838563ce/nixos/default.nix#L47
to be completely inside a mkIf. I guess using mkMerge. I'll see if I get an opportunity to fix it tomorrow. Thanks for reporting the bug!

rycee added a commit that referenced this issue Feb 26, 2019
vlaci pushed a commit to vlaci/blox that referenced this issue Mar 2, 2019
home-manager implementation was broken as it is now referencing
`users.users` too: nix-community/home-manager#594
'nixos-module-user-pkgs' feature has introduced circular dependencies
as blox already establishes a reference between the too attributes
where the dependency link has the opposite direction.

      /-------- via blox -------\
      |                         |
      |                         V
/-------------\         /--------------------\
| users.users | <------ | home-manager.users |
\-------------/         \--------------------/

This has been fixed by using the already existing `blox.users.users`
convenience attribute to derive both `home-manager.users` and
`users.users`.

          /------------------\
      /-- | blox.users.users | --\
      |   \------------------/   |
      |                          |
      V                          V
/-------------\         /--------------------\
| users.users | <------ | home-manager.users |
\-------------/         \--------------------/

WARNING: This breaks configurations which doesn't use
`blox.users.users`.
vlaci pushed a commit to vlaci/blox that referenced this issue Mar 2, 2019
home-manager implementation was broken as it is now referencing
`users.users` too: nix-community/home-manager#594
'nixos-module-user-pkgs' feature has introduced circular dependencies
as blox already establishes a reference between the too attributes
where the dependency link has the opposite direction.

```
      /-------- via blox -------\
      |                         |
      |                         V
/-------------\         /--------------------\
| users.users | <------ | home-manager.users |
\-------------/         \--------------------/
```

This has been fixed by using the already existing `blox.users.users`
convenience attribute to derive both `home-manager.users` and
`users.users`.

```
          /------------------\
      /-- | blox.users.users | --\
      |   \------------------/   |
      |                          |
      V                          V
/-------------\         /--------------------\
| users.users | <------ | home-manager.users |
\-------------/         \--------------------/
```

*WARNING*: This breaks configurations which doesn't use
`blox.users.users`.
@vlaci
Copy link
Author

vlaci commented Mar 2, 2019

I have fixed this issue on my side. I have already created my own users.users wrapper where I can set all the attributes I need and use that as a single source of truth to assign both home-manager.users and users.users in a similar fassion @kalbasit does.

Thank you for the effort you have put in investigating this.
Cheers!

@vlaci vlaci closed this as completed Mar 2, 2019
JustTNE added a commit to garuda-linux/home-manager that referenced this issue Aug 21, 2023
JustTNE added a commit to garuda-linux/home-manager that referenced this issue Aug 21, 2023
JustTNE added a commit to garuda-linux/home-manager that referenced this issue Aug 21, 2023
Fixes a regression of GitHub issue nix-community#594. Before this commit, attempting to dynamically configure home-manager with contents of nixos's users.users when using the nixos module would result in infinite recursion.
Fixes nix-community#594
rycee pushed a commit that referenced this issue Aug 22, 2023
Fixes a regression of GitHub issue #594. Before this commit,
attempting to dynamically configure Home Manager with contents of
nixos's users.users when using the nixos module would result in
infinite recursion.

PR #4368
@AkechiShiro
Copy link

AkechiShiro commented Sep 26, 2023

Is there any recommended way to do this nowadays? Using perhaps, only home-manager ?

@hraban
Copy link
Contributor

hraban commented Nov 18, 2023

Thanks for fixing, @rycee -- I use this and it's a nice feature

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants