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
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,12 @@ den.aspects.my-laptop = {
};
```

> NOTE: `_` is an alias for `provides`. In many examples you will see `foo._.bar._.baz` instead of `foo.provides.bar.provides.baz`.
> **TIP**
> **`_`** is an alias for `provides`. In many examples you will see `foo._.bar._.baz` instead of `foo.provides.bar.provides.baz`.

> **NOTE**
> Den provides an [__angle-brackets__](https://fzakaria.com/2025/08/10/angle-brackets-in-a-nix-flake-world) **experimental feature** that allows even shorter syntax for deep `.provide.` access.
> See [import-non-dendritic.nix](https://github.com/vic/den/pull/38/files) for an example usage.

</td>
<td>
Expand Down
17 changes: 16 additions & 1 deletion modules/lib.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,25 @@ let
{ class, aspect-chain }: funk aspect param;

aspects = inputs.flake-aspects.lib lib;

# EXPERIMENTAL. __findFile to resolve deep aspects.
# __findFile = angleBrackets den.aspects;
# <foo/bar/baz> => den.aspects.foo.provides.bar.provides.baz
# inspired by https://fzakaria.com/2025/08/10/angle-brackets-in-a-nix-flake-world
angleBrackets =
den-ns: _nixPath: name:
lib.pipe name [
(lib.replaceString "/" ".provides.")
(lib.splitString ".")
(path: lib.getAttrFromPath path den-ns)
];
in
{
config.den.lib = {
inherit parametric aspects;
inherit parametric aspects angleBrackets;

# default angle brackets search from den.aspects
__findFile = angleBrackets config.den.aspects;
};
options.den.lib = lib.mkOption {
readOnly = true;
Expand Down
15 changes: 11 additions & 4 deletions templates/default/modules/_example/import-non-dendritic.nix
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
# configures class-automatic module auto imports for hosts/users/homes.
# See documentation at modules/aspects/provides/import-tree.nix
{ den, ... }:
let
# EXPERIMENTAL FEATURE: __findFile enables angle brackets
# <import-tree/host> resolves to: den.provides.import-tree.provides.host
# See lib.nix and https://fzakaria.com/2025/08/10/angle-brackets-in-a-nix-flake-world
# deadnix: skip # this weird if is for my nixf-diagnose to skip unused __findFile.
__findFile = if true then den.lib.angleBrackets den.provides else __findFile;
in
{

# alice imports non-dendritic <class> modules from _non_dendritic/alice/_<class>/*.nix
den.aspects.alice.includes = [ (den._.import-tree ./_non_dendritic/alice) ];
den.aspects.alice.includes = [ (<import-tree> ./_non_dendritic/alice) ];

# See the documentation at batteries/import-tree.nix
den.default.includes = [
(den._.import-tree._.host ./_non_dendritic/hosts)
(den._.import-tree._.user ./_non_dendritic/users)
(den._.import-tree._.home ./_non_dendritic/homes)
(<import-tree/host> ./_non_dendritic/hosts)
(<import-tree/user> ./_non_dendritic/users)
(<import-tree/home> ./_non_dendritic/homes)
];

}