-
-
Notifications
You must be signed in to change notification settings - Fork 719
feat: add simple Nix flake for reproducible development environment #242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This provides a clean, maintainable alternative to the complex uv2nix approach in PR BeehiveInnovations#219. Benefits: - 90% less code (30 lines vs 280+ lines) - Uses standard buildPythonApplication from nixpkgs - No Python version bump needed (keeps 3.9+ support) - No uv.lock file required - Includes direnv support for automatic dev environment - Follows standard Nix patterns for easier maintenance The flake provides: - `nix build` - Build the package - `nix run` - Run zen-mcp-server directly - `nix develop` - Development shell with all dependencies - `nix profile install` - Install from GitHub Also includes .envrc for direnv users to automatically activate the development environment when entering the directory.
- Add Nix flake as development environment option alongside traditional setup - Document advantages: reproducible environment, zero setup, isolated dependencies - Include all available Nix commands (develop, build, run, install) - Explain direnv integration for automatic environment activation - Provide clear guidance for Nix users contributing to the project
This enables direnv to automatically load .env file contents into the environment, making nix run work correctly with API keys and other configuration from .env files. Before: nix run failed with missing API keys despite .env file After: nix run works correctly with environment loaded from .env Completes the Nix flake integration by ensuring configuration works seamlessly in both development and packaged environments.
- Simplified Python dependencies to avoid pydantic-core conflicts - Added LD_LIBRARY_PATH for proper shared library loading - Added pytest-asyncio for complete test compatibility - Modified run_integration_tests.sh to detect and work with Nix environment - Fixed integration tests to run successfully in both traditional and Nix environments All functionality now works properly: - nix develop: Full development environment with all tools - nix build/run: Working package build and execution - ./code_quality_checks.sh: All 799 unit tests pass - ./run_integration_tests.sh: Integration tests work in both environments
Uses Nix for system tools + pip venv for Python packages. Resolves pydantic binary issues while keeping Nix benefits. All tests now work in Nix environment.
Added .nix-venv exclusions to ruff, black, and isort commands to prevent formatting virtual environment files created by the Nix development shell.
- Added flake.lock for reproducible Nix builds - Added .nix-venv/, .direnv/, and result to .gitignore - Ensures clean git status with Nix development environment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @svnlto, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request introduces a simple Nix flake to provide a reproducible development environment for the Zen MCP Server. It offers a streamlined alternative to previous complex attempts by integrating Nix for system dependencies while maintaining a Python virtual environment for package management. The changes ensure cross-platform compatibility and zero breaking changes to existing workflows, making the development setup more robust and easier to manage.
Highlights
- Reproducible Development Environment: Implemented a simple Nix flake (
flake.nix
) for reproducible development, significantly reducing configuration complexity compared to prior attempts. - Hybrid Environment Setup: Established a hybrid development environment where Nix manages system dependencies and a Python virtual environment handles Python package management.
- Automated Environment Activation: Integrated
direnv
via a new.envrc
file to automatically activate the Nix development shell upon directory entry. - Tooling Integration: Updated
code_quality_checks.sh
andrun_integration_tests.sh
to properly handle the new Nix environment, excluding Nix-managed directories from checks and detecting Nix shell activation. - Documentation: Added comprehensive documentation in
docs/contributions.md
detailing the Nix setup, its benefits, and usage instructions for developers.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a simple and idiomatic Nix flake to provide a reproducible development environment, which is a great improvement for contributor onboarding and consistency. The implementation is clean and follows standard Nix patterns. My review focuses on improving the maintainability of the dependency management within the flake and ensuring the development environment is complete and robust. I've suggested changes to avoid hardcoding dependencies in the shellHook
and to include all necessary development packages.
- Add pytest-mock to devShell packages for complete test environment - Use pip install -e . for better dependency management from pyproject.toml - Add python-semantic-release to dev dependencies - Fix IN_NIX_SHELL detection to handle pure/impure values properly - Add standard pre-commit hooks for comprehensive formatting and validation - Update exclude patterns to include Nix development directories Standard hooks added: - trailing-whitespace, end-of-file-fixer for file consistency - check-yaml, check-json, check-toml for syntax validation - check-merge-conflict, check-added-large-files for safety - mixed-line-ending for consistent LF line endings
Summary
This PR adds a simple and idiomatic Nix flake for reproducible development environment setup, following the approach suggested in #219. This is a much simpler alternative to the closed PR #219 that had 280+ lines of complex configuration.
Key Features
flake.nix
): 63 lines vs 280+ in the previous attemptbuildPythonApplication
andmkShell
.envrc
): Automatic environment activationBenefits Over Previous Approach
./run-server.sh
setupFiles Added/Modified
flake.nix
- Simple Nix flake configuration with improved dependency managementflake.lock
- Nix lock file for reproducibility.envrc
- direnv configuration for auto-activation.gitignore
- Exclude Nix development artifactscode_quality_checks.sh
- Exclude.nix-venv
from checksrun_integration_tests.sh
- Robust Nix environment detectiondocs/contributions.md
- Document Nix development setup.pre-commit-config.yaml
- Added comprehensive standard hooks for code qualityPre-commit Improvements
Added standard pre-commit hooks for better code quality and consistency:
trailing-whitespace
,end-of-file-fixer
,mixed-line-ending
check-yaml
,check-json
,check-toml
check-merge-conflict
,check-added-large-files
.nix-venv/
,.direnv/
)Code Review Feedback Addressed
pytest-mock
to devShell packages for complete test environmentpip install -e .
for better dependency management frompyproject.toml
python-semantic-release
to development dependenciesIN_NIX_SHELL
detection to handlepure
/impure
values properlyUsage
This addresses the need for reproducible development environments while keeping the implementation simple and maintainable.
Test plan
nix build
)nix develop
)Fixes the need for Nix support mentioned in #219 with a much simpler approach, plus enhanced code quality tooling.