Debug Configurations
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 after debugging}Then in REPL:
nix-repl> :lf .nix-repl> den.aspects.igloonix-repl> den.hosts.x86_64-linux.igloonix-repl> den.ctxTrace Context
Section titled “Trace Context”Print context values during evaluation:
den.aspects.laptop.includes = [ ({ host, ... }@ctx: builtins.trace ctx { nixos.networking.hostName = host.hostName; })];Break into REPL
Section titled “Break into REPL”Drop into a REPL at any evaluation point:
den.aspects.laptop.includes = [ ({ host, ... }@ctx: builtins.break ctx { nixos = { }; })];Manually Resolve an Aspect
Section titled “Manually Resolve an Aspect”Test how an aspect resolves for a specific class:
nix-repl> module = den.lib.aspects.resolve "nixos" [] den.aspects.laptop;nix-repl> config = (lib.evalModules { modules = [ module ]; }).configFor parametric aspects, apply context first:
nix-repl> aspect = den.aspects.laptop { host = den.hosts.x86_64-linux.laptop; }nix-repl> module = den.lib.aspects.resolve "nixos" [] aspect;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> cfg = (lib.nixosSystem { modules = [ module ]; }).confignix-repl> cfg.networking.hostNameCommon Issues
Section titled “Common Issues”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).