nix-playgraound/notes/043-local-path-inputs.md

58 lines
1.4 KiB
Markdown

# Local Path Inputs
This note covers `40-path-inputs/`, which uses `inputs.catalog.url = "path:./catalog";` to pull another local flake into the parent flake.
---
## 1. What a Local Path Input Looks Like
A local input is declared with a `path:` flake reference:
```nix
inputs.catalog.url = "path:./catalog";
```
The target directory must itself be a flake, so `catalog/` contains its own `flake.nix`.
---
## 2. What the Child Flake Exposes
The child flake in this example does not build packages. It exports pure data through `lib`:
- one release name,
- one service-owner map, and
- one rollout plan.
The parent flake reads those values and turns them into a runnable script.
---
## 3. Why This Example Uses `lib`
Using `lib` keeps the focus on the input boundary, not on packaging details in both flakes.
That is the important part of `path:` inputs: once the child is a flake, its outputs are consumed the same way as any other flake input.
---
## 4. The Git-Tracked File Rule Still Applies
This is still a flake input, so Nix reads it from the flake source tree. Files inside `catalog/` must be tracked, or the parent flake will not see
them during pure evaluation.
That rule is easy to miss when the child flake lives in the same repository.
---
## 5. Commands to Try
```bash
cd 40-path-inputs
nix flake metadata
nix build
./result/bin/show-local-plan
nix flake check
```