Help us improve
Share bugs, ideas, or general feedback.
From nix-dev
Use for Nix debugging and troubleshooting including infinite recursion, hash mismatch, IFD import from derivation, build failures, nix log, nix why-depends, evaluation errors, attribute missing, unfree package errors, collision errors, builtins.trace, nix repl, nix eval, nix path-info, store paths, garbage collection, closure size analysis, or slow evaluation diagnosis.
npx claudepluginhub jylhis/claude-marketplace --plugin nix-devHow this skill is triggered — by the user, by Claude, or both
Slash command
/nix-dev:nix-debuggingThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
```
Provides behavioral guidelines to reduce common LLM coding mistakes, focusing on simplicity, surgical changes, assumption surfacing, and verifiable success criteria.
Searches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.
Structures git workflow practices for committing, branching, resolving conflicts, and organizing work across parallel streams. Use when making any code change.
Share bugs, ideas, or general feedback.
error: infinite recursion encountered
Causes:
rec { } where an attribute references itself circularlyfinal where prev is needed (or vice versa)mkIfDebug: Add builtins.trace calls to narrow down which attribute triggers it. In overlays, ensure you use prev.pkg for the package being modified and final.dep for dependencies.
error: hash mismatch in fixed-output derivation
specified: sha256-AAAA...
got: sha256-BBBB...
Fix: Replace the hash with the correct one from the error. Or use lib.fakeHash / "" during development to get the correct hash from the error.
error: attribute 'foo' missing
Debug:
# Check if it exists
nix eval nixpkgs#foo --apply 'x: builtins.typeOf x'
# List available attributes
nix eval nixpkgs#lib --apply builtins.attrNames
Common cause: typo in package name, or the package was renamed/removed in a nixpkgs update.
error: collision between '/nix/store/...-foo/bin/bar' and '/nix/store/...-baz/bin/bar'
Fix: One of the packages provides the same file. Use lib.hiPrio to prefer one, or remove the conflicting package:
home.packages = [
(lib.hiPrio pkgs.foo) # This one wins
pkgs.baz
];
error: cannot build during evaluation (import from derivation)
IFD happens when evaluation requires building something first. Common with generated Nix expressions. Fix by:
builtins.fetchurl instead of derivation-based fetchers during eval--allow-import-from-derivation (not recommended for CI)error: Package 'foo' has an unfree license ('unfree')
Fix:
# In flake or configuration
nixpkgs.config.allowUnfree = true;
# Or per-package
nixpkgs.config.allowUnfreePredicate = pkg:
builtins.elem (lib.getName pkg) [ "foo" ];
# CLI
NIXPKGS_ALLOW_UNFREE=1 nix build --impure
Print during evaluation:
let
x = builtins.trace "evaluating x" (1 + 1);
y = builtins.trace "x is ${toString x}" (x + 1);
in y
lib.traceVal x prints and returns x. lib.traceValSeq x forces deep evaluation before printing.
Show build logs for failed (or successful) builds:
nix log nixpkgs#hello # Log from last build
nix log /nix/store/...-hello # Log for specific store path
Trace why one package depends on another:
nix why-depends nixpkgs#myapp nixpkgs#gcc
Useful for understanding closure size and unexpected dependencies.
Inspect store paths:
nix path-info -rsSh nixpkgs#hello # Show closure size
nix path-info --json nixpkgs#hello # JSON output
Evaluate expressions without building:
nix eval nixpkgs#hello.version # "2.12.1"
nix eval nixpkgs#hello.meta.license.shortName # "gpl3Plus"
nix eval --expr 'builtins.attrNames (import <nixpkgs> {})' # List all packages
Interactive evaluation:
nix repl -f '<nixpkgs>'
# or
nix repl --expr 'import <nixpkgs> {}'
nix-repl> hello.version
"2.12.1"
nix-repl> lib.attrNames (lib.filterAttrs (n: v: lib.isDerivation v) python3Packages)
:lf . loads the current flake in the repl.
# Build with verbose output
nix build -L nixpkgs#hello
# Keep failed build directory for inspection
nix build --keep-failed nixpkgs#hello
# Failed build dir is printed: /tmp/nix-build-hello-xxx
# Override a phase interactively
nix develop nixpkgs#hello
# Then run phases manually:
unpackPhase
configurePhase
buildPhase
nix-collect-garbage # Remove unreferenced store paths
nix-collect-garbage -d # Also delete old profiles/generations
nix store gc # New CLI equivalent
nix store optimise # Deduplicate store (hardlinks)
# Check store integrity
nix store verify --all
# Show what would be deleted
nix-collect-garbage --print-dead
builtins.readDir on big directories, or deep recursive importsnix config show | grep substitutersnix path-info -rsSh and nix why-depends to find unexpected runtime dependencies