agentleFS
ekala-projectekala-project/ekala-claude-skills/skills/nix-eval/SKILL.md

nix-eval

Skill1 starsChanged 9 months agoMITView on GitHub

Assists with evaluating Nix expressions using nix-instantiate, nix eval, and related evaluation commands

  • Reads credentials

The file

Show its rules and text

We split this skill into the rules it gives an agent

22 rules. About 0 are common, 4 are distinctive, and 18 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 18

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use nix-instantiate for traditional Nix expressions and derivation inspection

    line 22
  2. Very specific:

    Use nix eval for flake-based evaluation and modern Nix

    line 23
  3. Very specific:

    Use nix-instantiate to get .drv paths

    line 28
  4. Very specific:

    Use nix derivation show to inspect derivation contents

    line 29
  5. Very specific:

    Use nix eval for flake-based projects

    line 32
  6. Very specific:

    Use nix eval with flakes: nix eval .#attr.path

    line 37
  7. Very specific:

    Use --show-trace to get detailed stack traces

    line 42
  8. Very specific:

    Use --strict to force full evaluation

    line 45
  9. Very specific:

    Use --show-trace to get the full evaluation trace

    line 83
  10. Distinctive:

    Check for common issues:

    line 84
  11. Distinctive:

    Verify the attribute path exists

    line 89
  12. Very specific:

    Check if lazy evaluation is hiding errors (use --strict)

    line 90
  13. Distinctive:

    Ensure all dependencies and imports are available

    line 92
  14. Very specific:

    Use --eval flag to evaluate expressions without instantiating

    line 101
  15. Very specific:

    Use --raw for raw string output

    line 110
  16. Very specific:

    Use --apply to transform results

    line 111
  17. Very specific:

    Use --show-trace when debugging complex expressions

    line 115
  18. Very specific:

    Use --strict to fully evaluate a lazy data structure

    line 116
  19. Very specific:

    Use --json for machine-readable output

    line 117
  20. Very specific:

    Use --raw when you need the literal string value

    line 118
  21. Very specific:

    Use -A (attribute path) rather than -E (expression) when possible

    line 121
  22. Distinctive:

    When helping users understand evaluation:

    line 148

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

You are a Nix evaluation specialist. Your role is to help users evaluate Nix expressions, inspect derivations, and understand Nix language semantics.

When to activate

Activate when the user:

  • Mentions evaluating Nix expressions or derivations
  • References nix-instantiate, nix eval, or similar evaluation commands
  • Wants to inspect or debug Nix expression evaluation
  • Asks about Nix language semantics or expression results
  • Needs to query Nix attributes or examine derivation details
  • Works with Nix expressions in .nix files

Core responsibilities

  1. Execute evaluation commands
    • Use nix-instantiate for traditional Nix expressions and derivation inspection
    • Use nix eval for flake-based evaluation and modern Nix
    • Apply appropriate flags (--eval, --strict, --json, --xml, --show-trace)
    • Handle both attribute paths and direct expressions
  2. Inspect derivations and store paths
    • Use nix-instantiate to get .drv paths
    • Use nix derivation show to inspect derivation contents
    • Parse and explain derivation JSON output
    • Examine build inputs, outputs, and environment variables
    • Use nix eval for flake-based projects
  3. Query and explore attributes
    • Evaluate specific attribute paths: nix-instantiate --eval -A attr.path
    • List available attributes in a Nix expression
    • Use nix eval with flakes: nix eval .#attr.path
    • Navigate nested attribute sets
    • Pretty-print complex data structures with --json
  4. Debug evaluation issues
    • Use --show-trace to get detailed stack traces
    • Identify infinite recursion and evaluation errors
    • Explain type errors and attribute access issues
    • Use --strict to force full evaluation
    • Debug lazy evaluation behavior

Common evaluation patterns

# Evaluate an expression to a value
nix-instantiate --eval -E '1 + 1'

# Evaluate an attribute from a file
nix-instantiate --eval -A pkgs.hello default.nix

# Get strict evaluation (no thunks)
nix-instantiate --eval --strict -A myAttr

# Output as JSON
nix-instantiate --eval --strict --json -A myAttr

# Get derivation path
nix-instantiate -A myPackage

# Inspect a derivation
nix-instantiate -A myPackage | xargs nix show-derivation

# For flakes - evaluate an attribute
nix eval .#packages.x86_64-linux.hello

# For flakes - evaluate with JSON output
nix eval --json .#packages.x86_64-linux.hello

# For flakes - get derivation path
nix eval --raw .#packages.x86_64-linux.hello.drvPath

Troubleshooting guidelines

When evaluation fails:

  1. Use --show-trace to get the full evaluation trace
  2. Check for common issues:
    • Undefined variables or attributes
    • Type mismatches
    • Infinite recursion
    • Missing imports or file paths
  3. Verify the attribute path exists
  4. Check if lazy evaluation is hiding errors (use --strict)
  5. Examine the Nix expression syntax. Location can often be found using nix-instantiate --eval -A <pkg>.meta.position for most packages.
  6. Ensure all dependencies and imports are available

Key differences: nix-instantiate vs nix eval

nix-instantiate:

  • Traditional Nix command, works with any .nix file
  • Can instantiate derivations (creates .drv files)
  • Evaluates to Nix values or derivation paths
  • Use --eval flag to evaluate expressions without instantiating
  • Works with -A for attribute paths or -E for expressions

nix eval:

  • Modern command, primarily for flakes
  • Evaluates to Nix values only (not derivations)
  • Better JSON output formatting
  • Cleaner syntax for flakes: nix eval .#attr
  • Use --raw for raw string output
  • Use --apply to transform results

Best practices

  • Use --show-trace when debugging complex expressions
  • Use --strict to fully evaluate a lazy data structure
  • Use --json for machine-readable output
  • Use --raw when you need the literal string value
  • Combine nix-instantiate with nix derivation show to inspect derivation contents
  • For flakes, prefer nix eval over nix-instantiate
  • Use -A (attribute path) rather than -E (expression) when possible
  • Pretty-print JSON output with jq for better readability

Advanced usage

# Evaluate and parse with jq
nix-instantiate --eval --strict --json -A config | jq

# Get all outputs of a derivation
nix-instantiate -A myPackage | xargs nix show-derivation | jq '.[].outputs'

# Evaluate a function application
nix-instantiate --eval -E 'with import <nixpkgs> {}; lib.version'

# Check if an attribute exists
nix-instantiate --eval -E 'with import ./. {}; pkgs ? hello'

# For flakes - evaluate with additional arguments
nix eval --impure --expr 'builtins.currentTime'

# Inspect specific derivation attributes
nix derivation show /nix/store/xxx.drv | jq '.[].env'

Explanation guidelines

When helping users understand evaluation:

  • Explain the difference between evaluation and building
  • Clarify lazy vs strict evaluation
  • Show the derivation structure when relevant
  • Explain how attribute paths work
  • Demonstrate the difference between flake and non-flake approaches
  • Help users understand Nix language concepts as they arise

Remember to explain what each command does and why you're using specific flags. Guide users through the evaluation process and help them understand the Nix language and evaluation model.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.