Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

programs.claude-code.enable

Whether to enable Claude Code, Anthropic’s official CLI.

Type: boolean

Default:

false

Example:

true

Declared by:

programs.claude-code.enableMcpIntegration

Whether to integrate the MCP servers config from programs.mcp.servers into programs.claude-code.mcpServers.

Note: Settings defined in programs.mcp.servers are merged with programs.claude-code.mcpServers, with Claude Code servers taking precedence.

Servers marked disabled (via enabled = false or disabled = true) are still written to .mcp.json but rejected through disabledMcpjsonServers in settings.json, since Claude Code has no per-server enabled field. This keeps a disabled server present (and re-enableable) instead of dropping it.

Type: boolean

Default:

false

Declared by:

programs.claude-code.package

The claude-code package to use.

Type: null or package

Default:

pkgs.claude-code

Declared by:

programs.claude-code.agents

Custom agents for Claude Code. The attribute name becomes the agent filename, and the value is either:

  • Inline content as a string with frontmatter
  • A path to a file containing the agent content with frontmatter Agents are stored in the agents/ subdirectory of programs.claude-code.configDir.

Type: attribute set of (strings concatenated with “\n” or absolute path)

Default:

{ }

Example:

{
  code-reviewer = ''
    ---
    name: code-reviewer
    description: Specialized code review agent
    tools: Read, Edit, Grep
    ---

    You are a senior software engineer specializing in code reviews.
    Focus on code quality, security, and maintainability.
  '';
  documentation = ./agents/documentation.md;
}

Declared by:

programs.claude-code.agentsDir

Path to a directory containing agent files for Claude Code. Agent files from this directory will be symlinked into the agents/ subdirectory of programs.claude-code.configDir.

Type: null or absolute path

Default:

null

Example:

./agents

Declared by:

programs.claude-code.commands

Custom commands for Claude Code. The attribute name becomes the command filename, and the value is either:

  • Inline content as a string
  • A path to a file containing the command content Commands are stored in the commands/ subdirectory of programs.claude-code.configDir.

Type: attribute set of (strings concatenated with “\n” or absolute path)

Default:

{ }

Example:

{
  changelog = ''
    ---
    allowed-tools: Bash(git log:*), Bash(git diff:*)
    argument-hint: [version] [change-type] [message]
    description: Update CHANGELOG.md with new entry
    ---
    Parse the version, change type, and message from the input
    and update the CHANGELOG.md file accordingly.
  '';
  fix-issue = ./commands/fix-issue.md;
  commit = ''
    ---
    allowed-tools: Bash(git add:*), Bash(git status:*), Bash(git commit:*)
    description: Create a git commit with proper message
    ---
    ## Context

    - Current git status: !`git status`
    - Current git diff: !`git diff HEAD`
    - Recent commits: !`git log --oneline -5`

    ## Task

    Based on the changes above, create a single atomic git commit with a descriptive message.
  '';
}

Declared by:

programs.claude-code.commandsDir

Path to a directory containing command files for Claude Code. Command files from this directory will be symlinked into the commands/ subdirectory of programs.claude-code.configDir.

Type: null or absolute path

Default:

null

Example:

./commands

Declared by:

programs.claude-code.configDir

Directory holding Claude Code’s configuration files.

Defaults to ~/.claude, matching the upstream claude CLI default. The CLAUDE_CONFIG_DIR environment variable is exported automatically whenever the directory differs from this default so the CLI reads configuration from the same location.

Type: string

Default:

"${config.home.homeDirectory}/.claude"

Example:

"${config.xdg.configHome}/claude"

Declared by:

programs.claude-code.context

Global context for Claude Code.

The value is either:

  • Inline content as a string
  • A path to a file containing the content

The configured content is written to CLAUDE.md inside programs.claude-code.configDir (default ~/.claude/CLAUDE.md).

Type: strings concatenated with “\n” or absolute path

Default:

""

Example:

./claude-memory.md

Declared by:

programs.claude-code.hooks

Custom hooks for Claude Code. The attribute name becomes the hook filename, and the value is the hook script content. Hooks are stored in the hooks/ subdirectory of programs.claude-code.configDir.

Type: attribute set of strings concatenated with “\n”

Default:

{ }

Example:

{
  post-commit = ''
    #!/usr/bin/env bash
    echo "Committed with message: $1"
  '';
  pre-edit = ''
    #!/usr/bin/env bash
    echo "About to edit file: $1"
  '';
}

Declared by:

programs.claude-code.hooksDir

Path to a directory containing hook files for Claude Code. Hook files from this directory will be symlinked into the hooks/ subdirectory of programs.claude-code.configDir.

Type: null or absolute path

Default:

null

Example:

./hooks

Declared by:

programs.claude-code.lspServers

LSP (Language Server Protocol) servers configuration.

Type: attribute set of (JSON value)

Default:

{ }

Example:

{
  go = {
    args = [
      "serve"
    ];
    command = "gopls";
    extensionToLanguage = {
      ".go" = "go";
    };
  };
  typescript = {
    args = [
      "--stdio"
    ];
    command = "typescript-language-server";
    extensionToLanguage = {
      ".js" = "javascript";
      ".jsx" = "javascriptreact";
      ".ts" = "typescript";
      ".tsx" = "typescriptreact";
    };
  };
}

Declared by:

programs.claude-code.marketplaces

Custom marketplaces for Claude Code plugins. The attribute name becomes the marketplace name, and the value is either:

  • A path to the marketplace directory
  • The marketplace package, whether a nix package or the output of a fetcher

Type: attribute set of (package or absolute path)

Default:

{ }

Example:

{
  local-marketplace = ./my-local-marketplace;
  gh-marketplace = fetchFromGithub {
    owner = "some-github-org";
    repo = "claude-marketplace";
    rev = "8a873a220b8427b25b03ce1a821593a24e098c34";
    sha256 = "5c2dce95122b5bb73fa547edabbb6c3061c2d193d11e51faecd4d22659e67279";
  };
}

Declared by:

programs.claude-code.mcpServers

MCP (Model Context Protocol) servers configuration

Type: attribute set of (JSON value)

Default:

{ }

Example:

{
  customTransport = {
    customOption = "value";
    timeout = 5000;
    type = "websocket";
    url = "wss://example.com/mcp";
  };
  database = {
    args = [
      "-y"
      "@bytebase/dbhub"
      "--dsn"
      "postgresql://user:pass@localhost:5432/db"
    ];
    command = "npx";
    env = {
      DATABASE_URL = "postgresql://user:pass@localhost:5432/db";
    };
    type = "stdio";
  };
  filesystem = {
    args = [
      "-y"
      "@modelcontextprotocol/server-filesystem"
      "/tmp"
    ];
    command = "npx";
    type = "stdio";
  };
  github = {
    type = "http";
    url = "https://api.githubcopilot.com/mcp/";
  };
}

Declared by:

programs.claude-code.outputStyles

Custom output styles for Claude Code. The attribute name becomes the base of the output style filename. The value is either:

  • Inline content as a string
  • A path to a file In both cases, the contents will be written to output-styles/<name>.md inside programs.claude-code.configDir.

Type: attribute set of (strings concatenated with “\n” or absolute path)

Default:

{ }

Example:

{
  concise = ./output-styles/concise.md;
  detailed = ''
    # Detailed Output Style

    Contents will be used verbatim for the detailed output format.
  '';
}

Declared by:

programs.claude-code.plugins

List of plugins to use when running Claude Code. Each entry is either:

  • A path to the plugin directory
  • The plugin package, whether a nix package or the output of a fetcher Plugins are enabled via a --plugin-dir argument in the wrapper script.

Type: list of (package or absolute path)

Default:

[ ]

Example:

[
  ./my-local-plugin
  fetchFromGithub {
    owner = "some-github-org";
    repo = "claude-plugin";
    rev = "779a68ebc2a75e4a184d2c87e5a43a758e6458a1";
    sha256 = "228fdd7e5908ea1d2f65218ecd9c71e1eefa0834d200d55fbb8bf8b5563acec0";
  }
]

Declared by:

programs.claude-code.rules

Modular rule files for Claude Code. The attribute name becomes the rule filename, and the value is either:

  • Inline content as a string
  • A path to a file containing the rule content Rules are stored in the rules/ subdirectory of programs.claude-code.configDir. All markdown files in that directory are automatically loaded as project memory.

Type: attribute set of (strings concatenated with “\n” or absolute path)

Default:

{ }

Example:

{
  code-style = ''
    # Code Style Guidelines

    - Use consistent formatting
    - Follow language conventions
  '';
  testing = ''
    # Testing Conventions

    - Write tests for all new features
    - Maintain test coverage above 80%
  '';
  security = ./rules/security.md;
}

Declared by:

programs.claude-code.rulesDir

Path to a directory containing rule files for Claude Code. Rule files from this directory will be symlinked into the rules/ subdirectory of programs.claude-code.configDir. All markdown files in this directory are automatically loaded as project memory.

Type: null or absolute path

Default:

null

Example:

./rules

Declared by:

programs.claude-code.settings

JSON configuration for Claude Code settings.json

Type: JSON value

Default:

{ }

Example:

{
  hooks = {
    PostToolUse = [
      {
        hooks = [
          {
            command = "nix fmt $(jq -r '.tool_input.file_path' <<< '$CLAUDE_TOOL_INPUT')";
            type = "command";
          }
        ];
        matcher = "Edit|MultiEdit|Write";
      }
    ];
    PreToolUse = [
      {
        hooks = [
          {
            command = "echo 'Running command: $CLAUDE_TOOL_INPUT'";
            type = "command";
          }
        ];
        matcher = "Bash";
      }
    ];
  };
  includeCoAuthoredBy = false;
  model = "claude-3-5-sonnet-20241022";
  permissions = {
    additionalDirectories = [
      "../docs/"
    ];
    allow = [
      "Bash(git diff:*)"
      "Edit"
    ];
    ask = [
      "Bash(git push:*)"
    ];
    defaultMode = "acceptEdits";
    deny = [
      "WebFetch"
      "Bash(curl:*)"
      "Read(./.env)"
      "Read(./secrets/**)"
    ];
    disableBypassPermissionsMode = "disable";
  };
  statusLine = {
    command = "input=$(cat); echo \"[$(echo \"$input\" | jq -r '.model.display_name')] 📁 $(basename \"$(echo \"$input\" | jq -r '.workspace.current_dir')\")\"";
    padding = 0;
    type = "command";
  };
  theme = "dark";
}

Declared by:

programs.claude-code.skills

Custom skills for Claude Code.

This option can be either:

  • An attribute set defining skills
  • A path to a directory containing skill folders

If an attribute set is used, the attribute name becomes the skill directory name, and the value is either:

  • Inline content as a string (creates skills/<name>/SKILL.md)
  • A path to a file (creates skills/<name>/SKILL.md)
  • A path to a directory (creates skills/<name>/ with all files)

This also accepts Nix store paths, for example a skill directory from a package.

If a path is used, it is expected to contain one folder per skill name, each containing a SKILL.md. The directory is symlinked into the skills/ subdirectory of programs.claude-code.configDir.

Type: (attribute set of (strings concatenated with “\n” or absolute path or string)) or absolute path

Default:

{ }

Example:

{
  xlsx = ./skills/xlsx/SKILL.md;
  data-analysis = ./skills/data-analysis;
  pdf-processing = ''
    ---
    name: pdf-processing
    description: Extract text and tables from PDF files, fill forms, merge documents. Use when working with PDF files or when the user mentions PDFs, forms, or document extraction.
    ---

    # PDF Processing

    ## Quick start

    Use pdfplumber to extract text from PDFs:

    ```python
    import pdfplumber

    with pdfplumber.open("document.pdf") as pdf:
        text = pdf.pages[0].extract_text()
    ```
  '';

  # A skill can also be a subdirectory within a package source (store path)
  beads = "${pkgs.beads.src}/claude-plugin/skills/beads";
}

Declared by: