Debug Configurations
builtins.trace
Section titled “builtins.trace”Print values during evaluation:
den.aspects.foo = { user, ... }@context: (builtins.trace context { nixos = { }; });builtins.break
Section titled “builtins.break”Drop into a REPL at any evaluation point:
den.aspects.foo = { user, ... }@context: (builtins.break context { nixos = { }; });Trace Context Keys
Section titled “Trace Context Keys”See which contexts are being applied:
den.default.includes = [ (context: builtins.trace (builtins.attrNames context) { })];REPL Inspection
Section titled “REPL Inspection”Load your flake and explore interactively:
$ nix replnix-repl> :lf .nix-repl> nixosConfigurations.igloo.config.networking.hostName"igloo"Expose den for Inspection
Section titled “Expose den for Inspection”Temporarily expose the den attrset as a flake output:
{ den, ... }: { flake.den = den; # remove when done}Then in REPL:
nix-repl> :lf .nix-repl> den.aspects.igloonix-repl> den.hosts.x86_64-linux.iglooManually Resolve an Aspect
Section titled “Manually Resolve an Aspect”Test how an aspect resolves for a specific class:
nix-repl> module = den.aspects.foo.resolve { class = "nixos"; aspect-chain = []; }nix-repl> config = (lib.evalModules { modules = [ module ]; }).configFor parametric aspects, apply context first:
nix-repl> aspect = den.aspects.foo { host = den.hosts.x86_64-linux.igloo; }nix-repl> module = aspect.resolve { class = "nixos"; aspect-chain = []; }Inspect a Host’s Main Module
Section titled “Inspect a Host’s Main Module”nix-repl> module = den.hosts.x86_64-linux.igloo.mainModulenix-repl> config = (lib.nixosSystem { modules = [ module ]; }).configCommon Issues
Section titled “Common Issues”Duplicate values in lists: Your function matches too many contexts.
Use den.lib.take.exactly to restrict matching:
den.lib.take.exactly ({ host }: { nixos.x = 1; })Missing attribute: The context doesn’t have the expected parameter. Trace context keys to see what’s available.
Infinite recursion: Aspects including each other in a cycle.
Check your includes chains for circular dependencies.