Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
936b674
refactor: remove diag library, add den-gram input, expose capture
sini May 21, 2026
e029cd9
test: update diag tests for den-gram extraction
sini May 21, 2026
903a631
refactor: migrate diagram-demo and fleet-demo to den-gram
sini May 21, 2026
72e521c
refactor: move diagram tests to den-gram, keep capture tests
sini May 21, 2026
3bbd13b
rename: den-gram → den-diagram
sini May 21, 2026
5bc3889
docs: update CLAUDE.md for den-diagram extraction
sini May 21, 2026
0d3077d
fix: treefmt exclude CLAUDE.md, fix markdown list spacing
sini May 21, 2026
336200c
fix: update den-diagram references to denful org
sini May 21, 2026
30c754b
docs: remove accidentally commited specs
sini May 21, 2026
4d3daaf
docs: update diagram references for den-diagram extraction
sini May 21, 2026
9dc137e
refactor: rename gram to diagram across API
sini May 21, 2026
8c5f249
chore: lock den-diagram input in templates
sini May 21, 2026
8e348db
refactor: rename inherit_ to inherit' in scope ancestry walker
sini May 22, 2026
2e6dab3
refactor(templates): use projectScope for per-entity diagram views
sini May 25, 2026
0ae9277
chore: pin templates den-diagram to main (projectScope merged)
sini May 25, 2026
bcf8833
chore: fix formatting on upstream README.md
sini Jun 5, 2026
af0ffe1
docs: update flake-aspects spec to reflect Palmer flat typing impleme…
sini May 20, 2026
2affca3
feat: add gen-schema flake input to CI template
sini May 20, 2026
e6824de
feat: port den.schema to gen-schema mkSchemaOption
sini May 21, 2026
c8dd6a6
feat: support flat host declarations alongside legacy two-level form
sini May 21, 2026
a4d7185
feat: port den.homes to support flat and legacy two-level forms
sini May 21, 2026
e4a5925
test: add entity gen-schema port tests
sini May 21, 2026
4bd8845
chore: rename den-schema to gen-schema
sini May 21, 2026
9b4b04b
feat: isEntity as settable sidecar with computed fallback
sini May 22, 2026
6b8a579
feat: update gen-schema, add parent sidecars for user/home, fix compu…
sini May 22, 2026
a4c4640
feat: reserve 'settings' as structural key on aspects
sini May 22, 2026
cc3d95f
feat: den.reservedKeys — user-extensible structural keys for aspects
sini May 22, 2026
2576eb8
fix: update for gen-schema collections rename and nix-effects v0.12
sini May 25, 2026
2a8cae7
chore: update gen-schema
sini May 27, 2026
da7cb0e
chore: update flake.lock
sini May 28, 2026
ba7f70d
chore: update flake.lock
sini May 28, 2026
c8c3215
feat(aspects): add entity.aspects accessor for resolved nodes
sini Jun 3, 2026
1b56211
feat(policy): add `self` guard — fire once at the registration scope
sini Jun 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ nix/ — all library and flake-module code
aspect/ — children, normalize, provide
policy/ — policy dispatch and effects
entities/ — host.nix, home.nix entity kind definitions
diag/ — diagram generation (c4, mermaid, dot, fleet views)
diag/capture.nix — trace capture (graph/rendering moved to denful/den-diagram)
nixModule/ — den.aspects, den.policies, den.lib option declarations
modules/ — NixOS-module-style option declarations and batteries
options.nix — den.hosts, den.homes, den.schema, den.classes, den.quirks
Expand Down Expand Up @@ -129,6 +129,35 @@ New test files must be `git add`'d before nix can evaluate them. Use `--override

- **den-debugging** (`.claude/skills/den-debugging.md`) — structured workflow for reproducing, isolating, and fixing bugs. Guides through: understand report → trace code path → write failing test → fix → validate. Includes an entry point table mapping symptoms to source files.

## Diagrams (den-diagram)

Diagram rendering lives in a separate repo: [denful/den-diagram](https://github.com/denful/den-diagram). Den keeps only the capture layer (`nix/lib/diag/capture.nix`) which runs the fx pipeline with tracing handlers.

**Capture** stays in den — `den.lib.capture.*`:

- `capture`, `captureAll`, `captureWithPaths`, `captureWithPathsWith`, `captureFleet`

**Rendering** lives in den-diagram — added as `inputs.den-diagram` in templates that need it:

```nix
diagram = inputs.den-diagram.lib;
# Two-step: capture in den, render in den-diagram
captured = den.lib.capture.captureWithPathsWith {
classes = [ "nixos" "homeManager" ];
root = den.lib.resolveEntity "host" { inherit host; };
ctx = { inherit host; };
};
g = diagram.context {
entries = captured.entries;
ctxTrace = captured.ctxTrace;
name = host.name;
};
rendered = diagram.toMermaid g;
```

Templates using den-diagram: `diagram-demo`, `fleet-demo`. Den's core flake and CI have no den-diagram dependency.

## Debugging and tracing

For pipeline debugging, use `builtins.trace` temporarily to inspect values flowing through handlers:
Expand Down
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

**Write a feature once. Run it on every host, user, and platform you have — and share it with anyone, flake or not.**

Den turns Nix configuration into composable **features** instead of per-host piles of modules. A Den *aspect* is a plain function: give it context (your hosts and users) and it returns configuration for every Nix class it touches — `nixos`, `darwin`, `homeManager`, `hjem`, or a class you invent.
Den turns Nix configuration into composable **features** instead of per-host piles of modules. A Den _aspect_ is a plain function: give it context (your hosts and users) and it returns configuration for every Nix class it touches — `nixos`, `darwin`, `homeManager`, `hjem`, or a class you invent.

```nix
# An aspect is a function of context that returns
Expand All @@ -33,8 +33,8 @@ That one idea — **a feature as a function** — is what makes the rest possibl
## What Den makes possible

- **One feature, everywhere, in one place.** Stop scattering a single concern across separate `nixos`, `darwin`, and `homeManager` files. An aspect holds all of it together.
- **Reuse across hosts, users — and across projects.** Share aspects between machines, between people, and between *flake and non-flake* setups, without forcing everyone to download each other's inputs.
- **No `mkIf` / `enable` clutter.** The shape of the context *is* the condition — a function that asks for `{ host, user }` simply doesn't run where there's no user. Conditionals disappear.
- **Reuse across hosts, users — and across projects.** Share aspects between machines, between people, and between _flake and non-flake_ setups, without forcing everyone to download each other's inputs.
- **No `mkIf` / `enable` clutter.** The shape of the context _is_ the condition — a function that asks for `{ host, user }` simply doesn't run where there's no user. Conditionals disappear.
- **Hosts shape their users, users shape their hosts.** Cross-entity configuration flows both ways, without coupling them together.
- **Add a capability in one line; remove it by deleting that line.** Hosts just pick the aspects they want.
- **Bring your own classes and whole pipelines.** Custom Nix classes, machine fleets, MicroVM guests, terranix, standalone neovim — if you can walk it as data, Den can configure it.
Expand All @@ -43,10 +43,10 @@ That one idea — **a feature as a function** — is what makes the rest possibl

Four concepts, one job each:

- **Entity** — *what exists*: a host, user, or home.
- **Aspect** — *what it does*: a feature, spanning Nix classes.
- **Policy** — *how entities relate*: topology and routing between them.
- **Quirk** — *structured data aspects share*, without coupling.
- **Entity** — _what exists_: a host, user, or home.
- **Aspect** — _what it does_: a feature, spanning Nix classes.
- **Policy** — _how entities relate_: topology and routing between them.
- **Quirk** — _structured data aspects share_, without coupling.

**Feature-first, not host-first.** Traditional setups start from hosts and push modules down; Den [flips that](https://den.denful.dev/explanation/core-principles/) — features are primary, hosts just select them.

Expand Down Expand Up @@ -75,11 +75,13 @@ nix run github:denful/den
## [Documentation](https://den.denful.dev)

**Start here**

- [From Zero to Den](https://den.denful.dev/guides/from-zero-to-den/)
- [From Flake to Den](https://den.denful.dev/guides/from-flake-to-den/)
- [Core Principles](https://den.denful.dev/explanation/core-principles/)

**Go further**

- [Custom Nix Classes](https://den.denful.dev/guides/custom-classes/)
- [Homes Integration](https://den.denful.dev/guides/home-manager/)
- [Batteries](https://den.denful.dev/guides/batteries/)
Expand All @@ -89,6 +91,7 @@ nix run github:denful/den
- [Tests as Code Examples](https://den.denful.dev/tutorials/ci/)

**Project**

- [Motivation](https://den.denful.dev/motivation/)
- [Versioning](https://den.denful.dev/releases/)
- [Community](https://den.denful.dev/community/)
Expand Down
1 change: 1 addition & 0 deletions checkmate/modules/formatter.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"docs/*"
"Justfile"
"AGENT*.md"
"CLAUDE.md"
"*.txt"
"*.svg"
"ci.bash"
Expand Down
2 changes: 1 addition & 1 deletion docs/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export default defineConfig({
{ label: 'den.policies', slug: 'reference/policies' },
{ label: 'den.lib', slug: 'reference/lib' },
{ label: 'den.lib', slug: 'reference/lib-deprecated', badge: { text: 'legacy', variant: 'note' } },
{ label: 'den.lib.diag', slug: 'reference/diag' },
{ label: 'den.lib.capture & den-diagram', slug: 'reference/diag' },
{ label: 'flake.*', slug: 'reference/output' },
{ label: 'Glossary', slug: 'reference/glossary' },
],
Expand Down
5 changes: 3 additions & 2 deletions docs/src/content/docs/explanation/diagrams.mdx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
---
title: Diagrams
description: Visualizing aspect resolution graphs with den.lib.diag.
description: Visualizing aspect resolution graphs with den-diagram.
---

import { Aside } from '@astrojs/starlight/components';

<Aside title="Source" icon="github">
[`nix/lib/diag/`](https://github.com/denful/den/tree/main/nix/lib/diag)
Capture: [`nix/lib/diag/capture.nix`](https://github.com/denful/den/blob/main/nix/lib/diag/capture.nix)
Rendering: [`denful/den-diagram`](https://github.com/denful/den-diagram)
</Aside>

## What it does
Expand Down
20 changes: 13 additions & 7 deletions docs/src/content/docs/guides/debug.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,21 @@ This returns a set of matching policies with their targets, routing type, and so

## Trace Aspect Includes

The resolution pipeline includes built-in tracing via the `diag` library.
Use `den.lib.diag.hostContext` to capture a full trace of which aspects are
included and how they resolve. See [Diagrams](/explanation/diagrams/) for details.
The resolution pipeline includes built-in tracing via `den.lib.capture` and the
[den-diagram](https://github.com/denful/den-diagram) library. Capture trace data
in den, then render with den-diagram. See [Diagrams](/explanation/diagrams/) for details.

```nix
# In a REPL:
diag = den.lib.diag
g = diag.hostContext { host = den.hosts.x86_64-linux.laptop; }
diag.toMermaid g # renders the full aspect graph
# In a REPL (with den-diagram available as `diagram`):
diagram = inputs.den-diagram.lib;
host = den.hosts.x86_64-linux.laptop;
captured = den.lib.capture.captureWithPathsWith {
classes = [ "nixos" "homeManager" ];
root = den.lib.resolveEntity "host" { inherit host; };
ctx = { inherit host; };
};
g = diagram.context { entries = captured.entries; name = host.name; };
diagram.toMermaid g # renders the full aspect graph
```

## Trace Context
Expand Down
2 changes: 1 addition & 1 deletion docs/src/content/docs/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Option namespaces and library functions.
<LinkCard title="den.policies" href="/reference/policies/" description="Policy effects, combinators, and built-in policies." />
<LinkCard title="den.ctx (compat)" href="/explanation/context-system/" description="Legacy compatibility shim." />
<LinkCard title="den.lib" href="/reference/lib/" description="Core library: aspect resolution, __findFile, policy constructors, nh wrappers." />
<LinkCard title="den.lib.diag" href="/reference/diag/" description="Diagram generation and graph introspection." />
<LinkCard title="den.lib.capture" href="/reference/diag/" description="Trace capture for diagram rendering (see den-diagram)." />
<LinkCard title="flake.*" href="/reference/output/" description="Output generation and instantiation." />
<LinkCard title="Glossary" href="/reference/glossary/" description="Definitions for Den-specific terms." />
</CardGrid>
Expand Down
Loading
Loading