Errors as Data & Yen vs NixOS Modules
Yen collects every type error, field conflict, and policy violation as structured JSON data ({ code; from; error; fix; near?; }) instead of stopping at the first throw or abort, and holds back deployable outputs until .#yen.ok is true.
1. Dead-sink warnings and custom errors
Section titled “1. Dead-sink warnings and custom errors”If a feature emits into a sink that nothing reads or forwards (like droppedFirewall below), Yen flags a dead-sink warning so silent typos never vanish.
And any aspect can emit into the built-in errors sink to fail a build closed with a clear message:
{ yen, std, types, reduce, ...}:{ imports = [ std.modules.all ];
# Unwired sink (no `into` and no `allowOrphan = true`): emitting to it triggers `dead-sink`. yen.kinds.host = { fields.backup = types.maybe yen.kinds.host; sinks.droppedFirewall.reduce = reduce.set; };
yen.host.web.addr = "198.51.100.10";
yen.aspects.web-base = { at = yen.host.web; nixos.services.nginx.enable = true; droppedFirewall = 80; };}{ yen, ... }:{ # Emit into the built-in `errors` sink to block outputs fail-closed yen.aspects.require-backup = { at = yen.kinds.host.where { backup = null; }; errors = { host, ... }: "host `${host.name}` has no backup target"; };}Inspect both warnings and blocking errors right from your shell:
nix eval --json .#yen.warningsnix eval --json .#yen.errors{ blockedOk = false; errors = [ { code = "error"; error = "host `web` has no backup target"; from = "host:web"; } ]; warnings = [ { code = "dead-sink"; sink = "nixos"; warning = "sink `nixos` received elements at 1 receiver(s) but has no reader or `into` forward"; } { code = "dead-sink"; sink = "droppedFirewall"; warning = "sink `droppedFirewall` received elements at 1 receiver(s) but has no reader or `into` forward"; } ];}2. NixOS modules vs Yen at a glance
Section titled “2. NixOS modules vs Yen at a glance”| Familiar NixOS / Home Manager pattern | How you do it in Yen |
|---|---|
Manual imports = [ ... ] + import-tree |
Pass ./modules to yen.mkFlake or yen.eval (_-prefixed paths skipped) |
mkHost helpers + specialArgs plumbing |
Typed yen.host.<name> records + { host, pkgs, config, ... }: directly in aspects |
String tags + lib.mkIf (host.role == "db") |
Checked ref enums (yen.gpu.nvidia) + at = yen.kinds.host.where { ... } |
lib.mkDefault / lib.mkForce priority layering |
Explicit two-answers on data conflicts + cascade, aspect settings, and reduce.layers |
| Duplicate list items on diamond imports | reduce.modules tags every module with its provenance key |
Per-host assertions that miss other hosts |
Whole-fleet yen.invariants + optional Lean 4 proof certificates |
Duplicating allowUnfreePredicate in OS + HM |
std.modules.resources bubbles unfree, firewall, persist, and secrets automatically |
| Copy-pasting MCP/skill configs across tools | Tool-agnostic shared sinks consumed independently by each tool |
Next, browse plain-English definitions of every Yen term in the Glossary.