import-tree
import-tree copied to clipboard
Create API for adding to scope
Extend the import-tree API so that users can easily add variable values that are automagically imported into every scope.
POC from @sini
inputs@{
import-tree,
flake-parts,
den,
...
}:
flake-parts.lib.mkFlake { inherit inputs; } {
imports = [
den.flakeModule
# Load all modules with scopedImport so <aspect> syntax works
# without per-file __findFile headers.
(
{ den, ... }:
{
imports = [
(import-tree.map (
path:
builtins.scopedImport {
inherit builtins den;
__findFile = den.lib.__findFile;
__nixPath = [ ];
} path
) ./modules)
];
}
)
];
}
Allows you to use den's <angle bracket> syntax without importing __findFile on each scope. Also allows you to reference den without importing it explicitly.
And then maybe some convenience functions around that? I don't know if a builder pattern like this is even possible with nix...
import-tree.withDen.withAngleBrackets.withPipe ./modules
Yep that is possible, but will be done at Den side. import-tree already provides addAPI and builder-pattern chains.
Fixed in #31