61 lines
1.4 KiB
Markdown
61 lines
1.4 KiB
Markdown
# Follows and Inputs
|
|
|
|
This note covers `15-follows-and-inputs/`, which defines multiple inputs and uses `follows` so one transitive input is reused instead of resolved
|
|
separately.
|
|
|
|
---
|
|
|
|
## 1. What `follows` Does
|
|
|
|
`follows` points one input at another input by name:
|
|
|
|
```nix
|
|
flake-utils = {
|
|
url = "github:numtide/flake-utils";
|
|
inputs.systems.follows = "systems";
|
|
};
|
|
```
|
|
|
|
That means `flake-utils` does not resolve its own separate `systems` input. It reuses the top-level `systems` input from this flake.
|
|
|
|
---
|
|
|
|
## 2. Why This Matters
|
|
|
|
Without `follows`, transitive dependencies can drift apart. Two flakes may each resolve their own copy of an input, even though you wanted them to
|
|
share one.
|
|
|
|
This example keeps the case small:
|
|
|
|
- one top-level `systems` input,
|
|
- one dependent flake, `flake-utils`, and
|
|
- one `follows` edge that ties them together.
|
|
|
|
That makes it easy to inspect with `nix flake metadata`.
|
|
|
|
---
|
|
|
|
## 3. Why the Example Still Builds Something
|
|
|
|
The flake uses `flake-utils.lib.eachDefaultSystem` so the dependency is not just declared, but actually used. The package itself stays trivial because
|
|
the point of the example is the input graph, not the package.
|
|
|
|
If you want to compare output-generation styles, see `03-multi-system/`. This example is about input wiring.
|
|
|
|
---
|
|
|
|
## 4. Commands to Try
|
|
|
|
```bash
|
|
cd 15-follows-and-inputs
|
|
|
|
nix flake metadata
|
|
nix flake show
|
|
|
|
nix build
|
|
./result/bin/show-follows
|
|
|
|
nix run
|
|
nix flake check
|
|
```
|