Thank you for your interest in contributing to this project! This guide will help you get started with development and testing.
To contribute or modify this project:
# Clone the repository
git clone https://github.com/roman/claude-code.nix
cd claude-code.nix
# Enter the development environment, this will install pre-commit hooks
nix develop
# Test with the example
cd examples/devenv-example
nix developRun the integration tests to ensure everything works correctly:
# From the project root
./tests/integration.shThe project includes several example configurations you can test:
examples/devenv-example/- Basic devenv integrationtests/fixtures/devenv-test/- devenv test fixturetests/fixtures/home-manager-test/- Home Manager test fixturetests/fixtures/edge-case-test/- Edge case testing
.
├── flake.nix # Main flake definition
├── presets.nix # MCP server preset definitions
├── tools.nix # Tool packaging and utilities
├── nix/
│ ├── lib/ # Shared library functions
│ ├── modules/ # Nix modules for devenv and Home Manager
│ └── packages/ # Package definitions for MCP servers
├── examples/ # Usage examples
└── tests/ # Test fixtures and scripts
- Add your preset definition to
presets.nix:
my-server = {
name = "My Server";
command = tools.getToolPath "my-server";
env = config: {
API_KEY_FILEPATH = config.apiKeyFilepath;
};
options = {
apiKeyFilepath = mkOption {
type = types.str;
description = lib.mdDoc "File containing API key";
example = "/var/run/agenix/my-server.key";
};
};
};- (Optional, if server not available in nixpkgs) Add the package definition in
nix/packages/:
# nix/packages/my-server/default.nix
{ lib, fetchFromGitHub, buildGoModule }:
buildGoModule {
pname = "my-server";
version = "1.0.0";
src = fetchFromGitHub {
owner = "example";
repo = "my-mcp-server";
rev = "v1.0.0";
hash = "sha256-...";
};
# ... rest of package definition
}- Update
tools.nixto include your new package.
!TIP
If the program doesn't allow filepaths for token inputs, use the
wrapWithCredentialFilesfunction with the mcp-server package derivation. Follow examples of other servers in the tools.nix file.This step is relevant as it will help avoid leaking credentials in the nix store.
Users can also add custom servers directly in their configuration:
mcp.servers.my-custom-server = {
type = "stdio";
command = "${pkgs.my-mcp-server}/bin/server";
args = [ "--option" "value" ];
env = {
API_KEY_FILE = "/path/to/api-key";
};
};- Always use file-based credential management instead of environment variables
- Never expose API tokens or keys in the Nix store
- Implement proper path restrictions for filesystem access
- Follow secure coding practices for new MCP server integrations
The project uses nixfmt for code formatting. Run formatting before submitting:
nix fmt- Fork the repository
- Create a feature branch
- Make your changes
- Test your changes with the integration tests
- Format your code with
nix fmt - Submit a pull request
If you need help or have questions:
- Open an issue on GitHub
- Check existing issues and discussions
- Review the examples and test fixtures for reference patterns
By contributing to this project, you agree that your contributions will be licensed under the MIT License.