Skip to content

Debug Configurations

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 after debugging
}

Then in REPL:

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

Print context values during evaluation:

den.aspects.laptop.includes = [
({ host, ... }@ctx: builtins.trace ctx {
nixos.networking.hostName = host.hostName;
})
];

Drop into a REPL at any evaluation point:

den.aspects.laptop.includes = [
({ host, ... }@ctx: builtins.break ctx {
nixos = { };
})
];

Test how an aspect resolves for a specific class:

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

For parametric aspects, apply context first:

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

Duplicate values in lists: Den deduplicates owned and static configs from den.default, but parametric functions in den.default.includes run at every context stage. Use den.lib.perHost to restrict:

den.lib.perHost ({ host }: { nixos.x = 1; })

Missing attribute: The context does not have the expected parameter. Trace context keys to see what is available.

Wrong class: Check that host.class matches what you expect. Darwin hosts have class = "darwin", not "nixos".

Module not found: Ensure the file is under modules/ and not prefixed with _ (excluded by import-tree).

Contribute Community Sponsor