nix-community / home-manager

Manage a user environment using Nix [maintainer=@rycee]
https://nix-community.github.io/home-manager/
MIT License
6.67k stars 1.75k forks source link

Bug: Using home-manager as a NixOS module with external authentication services (Kanidm, Ldap, Active Directory) fails #5244

Open TheRealGramdalf opened 5 months ago

TheRealGramdalf commented 5 months ago

Are you following the right branch?

Is there an existing issue for this?

Issue description

I use Kanidm to manage POSIX accounts on my small fleet of NixOS machines. I recently attempted to start using home-manager as a NixOS module, yet quickly ran into issues - the home-manager module expects to handle POSIX accounts itself (via users.users."therealgramdalf"), and thus throws an error:

       error:
       Failed assertions:
       - Exactly one of users.users.therealgramdalf.isSystemUser and users.users.therealgramdalf.isNormalUser must be set.

       - users.users.therealgramdalf.group is unset. This used to default to
       nogroup, but this is unsafe. For example you can create a group
       for this user with:
       users.users.therealgramdalf.group = "therealgramdalf";
       users.groups.therealgramdalf = {}

This is an issue, since the posix accounts don't actually exist locally on the machine - they are loaded dynamically by kanidm-unixd. I go more into detail here: https://github.com/kanidm/kanidm/issues/2698

A method to disable this requirement (such that the NixOS module doesn't actually create the users) should solve most of the problems; the UUID problems specified in the issue I linked should be solvable at the configuration level (without altering home-manager itself).

Maintainer CC

@rycee

System information

N/A
TheRealGramdalf commented 5 months ago

I should mention that I have home-manager.useUserPackages set to true, which may be affecting things due to the usage of users.users."therealgramdalf".packages

nixos-discourse commented 3 months ago

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/dealing-with-non-local-users-and-system-groups-home-manager/29145/3