Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions modules/aspects/provides/mutual-provider.nix
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@ let
find-mutual = from: to: den.aspects.${from.aspect}._.${to.aspect} or { };
user-to-hosts = user: den.aspects.${user.aspect}._.to-hosts or { };
host-to-users = host: den.aspects.${host.aspect}._.to-users or { };
user-to-users = user: den.aspects.${user.aspect}._.to-users or { };

mutual-user-user = host: user: {
includes = map (
from:
parametric.fixedTo { inherit host user; } {
includes = [
(find-mutual from user)
(user-to-users from)
];
}
) (builtins.filter (u: u != user) (builtins.attrValues host.users));
};

mutual-host-user =
{ host, user }:
Expand All @@ -47,6 +60,7 @@ let
(find-mutual user host)
(host-to-users host)
(user-to-hosts user)
(mutual-user-user host user)
];
};

Expand Down
48 changes: 48 additions & 0 deletions templates/ci/modules/features/user-host-mutual-config.nix
Original file line number Diff line number Diff line change
Expand Up @@ -244,5 +244,53 @@
}
);

test-user-provides-to-all-users = denTest (
{
den,
lib,
igloo,
...
}:
{
den.ctx.user.includes = [ den._.mutual-provider ];

den.hosts.x86_64-linux.igloo.users = {
tux = { };
alice = { };
bob = { };
carl = { };
};

den.aspects.tux.provides.to-users =
{ user, ... }:
{
homeManager.programs.vim.enable = true;
};

den.aspects.tux.provides.alice = {
homeManager.programs.tmux.enable = true;
};

expr = with igloo.home-manager.users; {
tux = tux.programs.vim.enable;
alice = alice.programs.vim.enable;
bob = bob.programs.vim.enable;
carl = carl.programs.vim.enable;
aliceTmux = alice.programs.tmux.enable;
bobTmux = bob.programs.tmux.enable;
};

expected = {
tux = false;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really understand why this is false here.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we avoid user providing to itself via mutual-provider. see filter at implementation

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for all users we have host._.to-users

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you :)

alice = true;
bob = true;
carl = true;
aliceTmux = true;
bobTmux = false;
};

}
);

};
}
Loading