mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 11:36:05 +01:00
nixos-module: Fix potential recursion between users.users and home-manager.users (#6622)
Pushing users.users.<name>.packages from matching home-manager users leads to a circular dependency when
one attribute set is calculated from the other.
A configuration pull approach replaces the previous one to break up the circular dependency. This new approach
allows more flexibility in configuring both option sets, including calculating from each other.
EXAMPLE;
```nix
{lib, /* custom arg */ flake, config, ...}: {
home-manager.useUserPackages = true;
home-manager.users = builtins.intersectAttrs (lib.filterAttrs (_: v: v.isNormalUser) config.users.users) (flake.outputs.homeModules.users);
}
```
EXAMPLE;
```nix
{lib, /* custom arg */ flake, config, ...}: {
home-manager.useUserPackages = true;
home-manager.users = { inherit (flake.outputs.homeModules.users) demo-user; };
users.users = lib.mapAttrs (_: _: { isNormalUser = true; }) (lib.filterAttrs (_: v: v.programs.git.enable) config.home-manager.users);
}
```
fixes #594
* options-manual: Remove `users` option set from documentation
The option declaration `users.users` is owned by the upstream
nixos modules and should not be documented by home-manager.
Home-manager declares an incomplete/partial option definition for
`users.users` that cannot be documented without the full definition from
the nixos modules. This partial definition is removed from the options
set while generating documentation for the home-manager nixos module.
This commit is contained in:
parent
b6fd653ef8
commit
216690777e
2 changed files with 19 additions and 9 deletions
|
|
@ -50,6 +50,13 @@ let
|
|||
};
|
||||
|
||||
in {
|
||||
options.users.users = mkOption {
|
||||
type = types.attrsOf (types.submodule ({ name, config, ... }: {
|
||||
config.packages = mkIf ((config.enable or true) && cfg.useUserPackages
|
||||
&& lib.hasAttr name cfg.users) [ cfg.users.${name}.home.path ];
|
||||
}));
|
||||
};
|
||||
|
||||
options.home-manager = {
|
||||
useUserPackages = mkEnableOption ''
|
||||
installation of user packages through the
|
||||
|
|
@ -104,10 +111,7 @@ in {
|
|||
};
|
||||
|
||||
config = (lib.mkMerge [
|
||||
# Fix potential recursion when configuring home-manager users based on values in users.users #594
|
||||
(mkIf (cfg.useUserPackages && cfg.users != { }) {
|
||||
users.users = (lib.mapAttrs
|
||||
(_username: usercfg: { packages = [ usercfg.home.path ]; }) cfg.users);
|
||||
environment.pathsToLink = [ "/etc/profile.d" ];
|
||||
})
|
||||
(mkIf (cfg.users != { }) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue