flyinggrizzly
MCP Serverflyinggrizzlypublic

claude nix

Nix home-manager flake to manage claude code config

Repository Info

2
Stars
2
Forks
2
Watchers
1
Issues
Nix
Language
MIT License
License

About This Server

Nix home-manager flake to manage claude code config

Model Context Protocol (MCP) - This server can be integrated with AI applications to provide additional context and capabilities, enabling enhanced AI interactions and functionality.

Documentation

Claude Nix

CAUTION

Claude currently has a bug where it can't read symlinked files, so this module **does not manage its files using Nix's standard add-to-store-and-symlink approach. Instead it adds them to the store, and then uses an activation script to copy the files to the right location. The main consequence of this is that if you don't set the forceClean flag, removing e.g. a command from your config won't remove it from the produced config.

forceClean exists to work around this, by cleaning up all commands before the current ones are copied in, but it is not able to preserve any non-Nix-tracked commands, so use it with caution, and create backups.

A Nix flake that provides a home-manager module for configuring Claude Code.

Features

  • Install the Claude Code CLI package (optional)
  • Configure command files in ~/.claude/commands/ by passing a directory and/or a list of individual files
  • Manage Claude memory in ~/.claude/CLAUDE.md
  • Configure MCP servers in ~/.claude.json
  • Support for standalone home-manager
  • Follows the -b <backup-ext> flag

Quick Start

Add this flake to your inputs:

{
  inputs = {
    # ...
    claude-nix.url = "github:flyinggrizzly/claude-nix";
  };
}

and a simple config:

{ ... }:
{
  config = {
    imports = [
      inputs.claude-nix.homeManagerModules.claude-code
    ];

    programs.claude-code = {
      enable = true;
      commandsDir = ./command-directory;
      commands = [ ./path/to/extra/command.md ];
      memory.source = ./my/claude.md;
      mcpServers = {
        github = {
          command = "docker";
          args = ["run" "-i" "--rm" "-e" "GITHUB_PERSONAL_ACCESS_TOKEN" "ghcr.io/github/github-mcp-server"];
          env = {
            # Don't store this as plain text. Use like, agenix or sops-nix or sumthing
            GITHUB_PERSONAL_ACCESS_TOKEN = "TOKEN";
          };
        };
      };
    };
  }
}

Configuration Options

OptionTypeDefaultDescription
enablebooleanfalseEnable Claude Code configuration
commandslist of paths[]Individual command files to copy to ~/.claude/commands/
commandsDirpathnullDirectory of markdown files to copy as commands
packagepackage or nullpkgs.claude-codeClaude Code package to install (or null to not install)
forceCleanbooleanfalseClean existing files before applying configuration
skipBackupbooleanfalseSkips backing up files even if the -b <backup-ext> option is set
memory.textstringnullContent to write to ~/.claude/CLAUDE.md
memory.sourcepathnullFile to copy to ~/.claude/CLAUDE.md (takes precedence over text)
mcpServersattrset{}MCP server configurations to merge into ~/.claude.json

Rationale and approach

Claude currently has a bug where it can't read symlinked files, which is why this flake uses the activation scripts to copy files into place (once the bug is resolved, the flake's API can remain the same but we can replace the scripts with actual nix config setup).

Additionally, Claude writes to ~/.claude.json so it can't be directly managed by Nix.

Development

# Format code
nix develop
nixpkgs-fmt .

# Run tests
nix flake check

License

This project is licensed under the MIT License - see the LICENSE file for details. Claude itself has proprietary licensing, plus nix and home-manager have their own shit. Go look it up.

Quick Start

1

Clone the repository

git clone https://github.com/flyinggrizzly/claude-nix
2

Install dependencies

cd claude-nix
npm install
3

Follow the documentation

Check the repository's README.md file for specific installation and usage instructions.

Repository Details

Ownerflyinggrizzly
Repoclaude-nix
LanguageNix
LicenseMIT License
Last fetched8/10/2025

Recommended MCP Servers

💬

Discord MCP

Enable AI assistants to seamlessly interact with Discord servers, channels, and messages.

integrationsdiscordchat
🔗

Knit MCP

Connect AI agents to 200+ SaaS applications and automate workflows.

integrationsautomationsaas
🕷️

Apify MCP Server

Deploy and interact with Apify actors for web scraping and data extraction.

apifycrawlerdata
🌐

BrowserStack MCP

BrowserStack MCP Server for automated testing across multiple browsers.

testingqabrowsers

Zapier MCP

A Zapier server that provides automation capabilities for various apps.

zapierautomation