diff --git a/README.md b/README.md index 31c9f7b..bf6d0b9 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/modules/lib.nix b/modules/lib.nix index 00377a1..7d475f7 100644 --- a/modules/lib.nix +++ b/modules/lib.nix @@ -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; + # => 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; diff --git a/templates/default/modules/_example/import-non-dendritic.nix b/templates/default/modules/_example/import-non-dendritic.nix index 9a210f2..9c93ba9 100644 --- a/templates/default/modules/_example/import-non-dendritic.nix +++ b/templates/default/modules/_example/import-non-dendritic.nix @@ -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 + # 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 modules from _non_dendritic/alice/_/*.nix - den.aspects.alice.includes = [ (den._.import-tree ./_non_dendritic/alice) ]; + den.aspects.alice.includes = [ ( ./_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) + ( ./_non_dendritic/hosts) + ( ./_non_dendritic/users) + ( ./_non_dendritic/homes) ]; }