mirror of
https://gitlab.com/rensa-nix/core.git
synced 2026-02-02 07:15:08 +01:00
feat: add autodiscovery for cell blocks
This commit is contained in:
parent
e08c48b5db
commit
50d96d43ce
10 changed files with 251 additions and 45 deletions
43
docs/api.md
43
docs/api.md
|
|
@ -8,7 +8,7 @@ The main entry point for creating a Rensa flake.
|
|||
|
||||
- `inputs`: The flake inputs.
|
||||
- `cellsFrom`: Path to the directory containing your cells.
|
||||
- `cellBlocks`: A list of blocks to load for each cell.
|
||||
- `cellBlocks`: A list of blocks to load for each cell. Defaults to `[rensa.blocks.autodiscover]`.
|
||||
- `transformInputs` (optional): A function to transform inputs before they are passed to cells.
|
||||
|
||||
### Returns
|
||||
|
|
@ -23,7 +23,7 @@ The underlying builder function used by `buildWith`. It returns the raw Rensa ou
|
|||
|
||||
- `inputs`: The flake inputs.
|
||||
- `cellsFrom`: Path to the directory containing your cells.
|
||||
- `cellBlocks`: A list of blocks to load for each cell.
|
||||
- `cellBlocks`: A list of blocks to load for each cell. Defaults to `[rensa.blocks.autodiscover]`.
|
||||
- `transformInputs` (optional): A function to transform inputs.
|
||||
|
||||
### Returns
|
||||
|
|
@ -56,6 +56,45 @@ by passing through actions etc. from a cell.
|
|||
|
||||
Currently not really used.
|
||||
|
||||
### `autodiscover`
|
||||
|
||||
```nix
|
||||
autodiscover
|
||||
# or
|
||||
(autodiscover "cellName")
|
||||
```
|
||||
|
||||
Automatically discovers and loads all cell blocks by scanning the cells directory for `.nix` files.
|
||||
When `autodiscover` is present in `cellBlocks`, Rensa will:
|
||||
|
||||
1. Walk through all cells in `cellsFrom` (or specific cell if provided).
|
||||
1. Find all `.nix` files (excluding `flake.nix`).
|
||||
1. Find all directories containing `default.nix`.
|
||||
1. Generate `simple` block definitions for each discovered block.
|
||||
|
||||
**Usage patterns:**
|
||||
|
||||
```nix
|
||||
# full autodiscovery
|
||||
cellBlocks = with rensa.blocks; [
|
||||
autodiscover
|
||||
];
|
||||
# or
|
||||
cellBlocks = with rensa.blocks; [
|
||||
(autodiscover "backend") # only discover blocks from backend cell
|
||||
(autodiscover "frontend") # only discover blocks from frontend cell
|
||||
];
|
||||
# mixed
|
||||
cellBlocks = with rensa.blocks; [
|
||||
(simple "myBlock") # explicit block (takes precedence)
|
||||
autodiscover # discover all others
|
||||
];
|
||||
```
|
||||
|
||||
!!! note
|
||||
|
||||
When a block is both explicitly defined and discovered, the explicit definition takes precedence.
|
||||
|
||||
## `rensa.select`
|
||||
|
||||
Helper to select specific outputs from the generated flake.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue