Skip to content

build: add nix flake packaging#316

Open
ReStranger wants to merge 1 commit intomksglu:mainfrom
ReStranger:nix-package
Open

build: add nix flake packaging#316
ReStranger wants to merge 1 commit intomksglu:mainfrom
ReStranger:nix-package

Conversation

@ReStranger
Copy link
Copy Markdown

@ReStranger ReStranger commented Apr 20, 2026

What / Why / How

Add Nix flake packaging for context-mode so the project can be built and run as a Nix package instead of only via npm-style installation. This adds a minimal flake-based package that wraps the bundled CLI with nodejs_22, includes the runtime assets the CLI expects next to itself, enables allowUnfree in the flake-local Nixpkgs import for the project's Elastic-2.0 license, and exposes the package as both packages.default and packages.context-mode plus an apps.default entry for nix run.

Affected platforms

  • Claude Code
  • Cursor
  • VS Code Copilot (GitHub Copilot)
  • Gemini CLI
  • OpenCode
  • KiloCode
  • Codex CLI
  • OpenClaw (Pi Agent)
  • Kiro
  • Antigravity
  • Zed
  • All platforms

Test plan

  • Build the package with nix build .#context-mode
  • Run ./result/bin/context-mode --help
  • Run ./result/bin/context-mode doctor
  • Run nix run .# -- --help
  • Verify bundled runtime detection includes node, tsx, and python3 from the wrapped PATH

Checklist

  • Tests added/updated (TDD: red → green)
  • npm test passes
  • npm run typecheck passes
  • Docs updated if needed (README, platform-support.md)
  • No Windows path regressions (forward slashes only)
  • Targets next branch (unless hotfix)
Cross-platform notes

Our CI runs on Ubuntu, macOS, and Windows.

  • This change does not modify application path handling logic; it only adds Nix packaging metadata and a wrapper script
  • The package uses the prebuilt cli.bundle.mjs and installs runtime assets alongside it, matching the existing relative-path expectations in the CLI
  • nodejs_22 is used so Linux builds can rely on the built-in SQLite path already supported by the project
  • allowUnfree is configured in the flake's local nixpkgs import, so users do not need --impure or external Nix config to build the package

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant