mirror of
https://gitlab.com/rensa-nix/core.git
synced 2026-02-01 23:05: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.
|
||||
|
|
|
|||
38
docs/debugging.md
Normal file
38
docs/debugging.md
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
# Debugging
|
||||
|
||||
## Error Context
|
||||
|
||||
To help with debugging, Rensa uses Nix's `builtins.addErrorContext` to add context
|
||||
about where an error is happening.
|
||||
|
||||
Use the following command to get just these logs from Rensa and please include that (or the whole stacktrace) in any issues or bug reports :)
|
||||
|
||||
```sh
|
||||
nix ... --show-trace 2> >(grep "… \[ren\]")
|
||||
```
|
||||
|
||||
## Trace Verbose
|
||||
|
||||
There are also some `traceVerbose` calls in Rensa, so to debug non-failing executions
|
||||
just run Nix with the `--trace-verbose` flag.
|
||||
|
||||
The output could look like this (example with this repo's flake):
|
||||
|
||||
```sh
|
||||
trace: [ren] loading cell block ci, type ci, from cell /nix/store/7acz6q9360fkg0x187yx43d1vwpv850l-cells/repo, for system aarch64-darwin
|
||||
trace: [ren] loading cell block devShells, type devShells, from cell /nix/store/7acz6q9360fkg0x187yx43d1vwpv850l-cells/repo, for system aarch64-darwin
|
||||
trace: [ren] loading cell block docs, type docs, from cell /nix/store/7acz6q9360fkg0x187yx43d1vwpv850l-cells/repo, for system aarch64-darwin
|
||||
trace: [ren] loading cell block soonix, type soonix, from cell /nix/store/7acz6q9360fkg0x187yx43d1vwpv850l-cells/repo, for system aarch64-darwin
|
||||
trace: [ren] loading cell block ci, type ci, from cell /nix/store/7acz6q9360fkg0x187yx43d1vwpv850l-cells/repo, for system aarch64-linux
|
||||
trace: [ren] loading cell block devShells, type devShells, from cell /nix/store/7acz6q9360fkg0x187yx43d1vwpv850l-cells/repo, for system aarch64-linux
|
||||
trace: [ren] loading cell block docs, type docs, from cell /nix/store/7acz6q9360fkg0x187yx43d1vwpv850l-cells/repo, for system aarch64-linux
|
||||
trace: [ren] loading cell block soonix, type soonix, from cell /nix/store/7acz6q9360fkg0x187yx43d1vwpv850l-cells/repo, for system aarch64-linux
|
||||
trace: [ren] loading cell block ci, type ci, from cell /nix/store/7acz6q9360fkg0x187yx43d1vwpv850l-cells/repo, for system x86_64-darwin
|
||||
trace: [ren] loading cell block devShells, type devShells, from cell /nix/store/7acz6q9360fkg0x187yx43d1vwpv850l-cells/repo, for system x86_64-darwin
|
||||
trace: [ren] loading cell block docs, type docs, from cell /nix/store/7acz6q9360fkg0x187yx43d1vwpv850l-cells/repo, for system x86_64-darwin
|
||||
trace: [ren] loading cell block soonix, type soonix, from cell /nix/store/7acz6q9360fkg0x187yx43d1vwpv850l-cells/repo, for system x86_64-darwin
|
||||
trace: [ren] loading cell block ci, type ci, from cell /nix/store/7acz6q9360fkg0x187yx43d1vwpv850l-cells/repo, for system x86_64-linux
|
||||
trace: [ren] loading cell block devShells, type devShells, from cell /nix/store/7acz6q9360fkg0x187yx43d1vwpv850l-cells/repo, for system x86_64-linux
|
||||
trace: [ren] loading cell block docs, type docs, from cell /nix/store/7acz6q9360fkg0x187yx43d1vwpv850l-cells/repo, for system x86_64-linux
|
||||
trace: [ren] loading cell block soonix, type soonix, from cell /nix/store/7acz6q9360fkg0x187yx43d1vwpv850l-cells/repo, for system x86_64-linux
|
||||
```
|
||||
Loading…
Add table
Add a link
Reference in a new issue