Skip to content

Debug Configurations

Print values during evaluation:

den.aspects.foo = { user, ... }@context:
(builtins.trace context {
nixos = { };
});

Drop into a REPL at any evaluation point:

den.aspects.foo = { user, ... }@context:
(builtins.break context {
nixos = { };
});

See which contexts are being applied:

den.default.includes = [
(context: builtins.trace (builtins.attrNames context) { })
];

Load your flake and explore interactively:

Terminal window
$ nix repl
nix-repl> :lf .
nix-repl> nixosConfigurations.igloo.config.networking.hostName
"igloo"

Temporarily expose the den attrset as a flake output:

{ den, ... }: {
flake.den = den; # remove when done
}

Then in REPL:

Terminal window
nix-repl> :lf .
nix-repl> den.aspects.igloo
nix-repl> den.hosts.x86_64-linux.igloo

Test how an aspect resolves for a specific class:

Terminal window
nix-repl> module = den.aspects.foo.resolve { class = "nixos"; aspect-chain = []; }
nix-repl> config = (lib.evalModules { modules = [ module ]; }).config

For parametric aspects, apply context first:

Terminal window
nix-repl> aspect = den.aspects.foo { host = den.hosts.x86_64-linux.igloo; }
nix-repl> module = aspect.resolve { class = "nixos"; aspect-chain = []; }
Terminal window
nix-repl> module = den.hosts.x86_64-linux.igloo.mainModule
nix-repl> config = (lib.nixosSystem { modules = [ module ]; }).config

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.