Managing user-specific home manager configs for the same aspect #636
Replies: 1 comment 2 replies
|
Your current approach does not mean the aspect model has broken down; it means “Firefox” and “Alice's choice of Firefox policy” are two different concerns. Den automatically creates an aspect for each user entity ( { den, ... }:
{
# Reusable invariant, only if there really is one.
den.aspects.firefox.base.homeManager = {
programs.firefox.enable = true;
};
den.aspects.firefox.declarative = {
includes = [ den.aspects.firefox.base ];
homeManager = {
# programs.firefox.profiles / policies / extensions / ...
};
};
den.aspects.firefox.raw-dotfiles = {
includes = [ den.aspects.firefox.base ];
homeManager = {
# xdg.configFile."..." = { source = ...; };
};
};
den.aspects.alice.includes = [
den.aspects.firefox.declarative
];
den.aspects.bob.includes = [
den.aspects.firefox.raw-dotfiles
];
}This leaves one line to change when adding a user, while the large implementations remain reusable and live under the Firefox feature tree. The dependency on For configuration that is truly unique and will never be reused, put it directly on the automatically created user aspect instead: den.aspects.alice.homeManager.imports = [
./users/alice/firefox.nix
];
den.aspects.bob.homeManager.imports = [
./users/bob/firefox.nix
];That is still aspect-oriented: the user entity aspect owns the user-specific policy, while the imported file merely keeps a long Home Manager module manageable. Den's example explicitly uses A third, data-driven option is useful only if you have many users choosing from the same small set of profiles: add a typed user-schema field such as So my rule of thumb would be:
This matches Den's documented split: entities describe what exists, aspects describe behavior, and each user entity automatically gets an aspect that can compose other aspects. References: |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi, pretty new to den here, coming from a more traditional dendritic setup with just flake-parts. I've been grappling with an architectural problem with dendritic pattern in general, and I'm really curious if den has an elegant solution for this that I haven't been able to see:
Say
aliceandbobare two users with different, and long, home manager configs for a feature like Firefox—perhapsalicewants declarative configs andbobwants toxdg.configFileraw dotfiles. How should you writeden.aspects.firefoxto accommodate this? It almost feels like the "reusable aspects" idea of den (and dendritic pattern in general) sort of breaks down in this case.Currently what I have going is to just provide a very minimal and unopinionated
den.aspects.firefoxthat basically does nothing butThen,
aliceandbobrespectively get sub-aspects that include this:and
(or perhaps
den.aspects.alice.firefoxandden.aspects.bob.firefoxinstead? although this feels less feature-oriented). Then,alice's user aspect includesden.aspects.firefox.aliceandbob's includesden.aspects.firefox.bob. (In my original dendritic setup without den, these subaspects were instead just private, regular nixos module thataliceandbobwould import by relative path.)However, this still feels pretty inelegant and somewhat hard to manage as new users come along (e.g. the subaspect having to include its "parent" aspect feels kind of cumbersome). Is there a nicer way to make this work? For example, would setting custom options within the user aspect to store configs and just referencing that in each aspect be more idiomatic?
(Apologies if I'm missing something obvious. I wasn't able to find many repos on github that had vastly differing home manager configs for each user, so help would be greatly appreciated!)
All reactions