Last active
February 10, 2026 13:46
-
-
Save blmarket/a43d4aebd15533ddc73b8939eb2e30ed to your computer and use it in GitHub Desktop.
Nix flake for pi - an AI coding agent from pi-mono
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| description = "Nix flake for pi - an AI coding agent from pi-mono"; | |
| inputs = { | |
| nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; | |
| flake-utils.url = "github:numtide/flake-utils"; | |
| }; | |
| outputs = { self, nixpkgs, flake-utils }: | |
| flake-utils.lib.eachDefaultSystem (system: | |
| let | |
| pkgs = import nixpkgs { | |
| inherit system; | |
| }; | |
| pi = pkgs.buildNpmPackage rec { | |
| pname = "pi"; | |
| version = "0.50.6"; | |
| src = pkgs.fetchFromGitHub { | |
| owner = "badlogic"; | |
| repo = "pi-mono"; | |
| rev = "022b20f364a3c0aa039050b1496eb0354c6bb962"; | |
| hash = "sha256-E3IvvwlMoKx6HM8yi5zgQdI9xHaQomIrEwOWQ8C9fvY="; | |
| }; | |
| npmDepsHash = "sha256-paLj+5m/Gx7bgubEJjwW0+082fpdoj6ZzThQ9oBy5PY="; | |
| nodejs = pkgs.nodejs_22; | |
| # Native build dependencies for canvas npm package | |
| nativeBuildInputs = with pkgs; [ | |
| pkg-config | |
| python3 | |
| makeWrapper | |
| ]; | |
| buildInputs = with pkgs; [ | |
| cairo | |
| pango | |
| libjpeg | |
| giflib | |
| librsvg | |
| pixman | |
| ]; | |
| # Build all packages | |
| npmBuildScript = "build"; | |
| # Skip the generate-models step since it requires network access | |
| # and the models.generated.ts file is already in the source | |
| preBuild = '' | |
| substituteInPlace packages/ai/package.json \ | |
| --replace-fail '"build": "npm run generate-models && tsgo -p tsconfig.build.json"' \ | |
| '"build": "tsgo -p tsconfig.build.json"' | |
| ''; | |
| # Don't use the default npm install hook, we need to preserve the dist directories | |
| dontNpmInstall = true; | |
| # Custom install phase that preserves the built dist directories | |
| installPhase = '' | |
| runHook preInstall | |
| # Create the lib directory structure | |
| mkdir -p $out/lib/node_modules/pi-monorepo | |
| # Copy the entire built source including node_modules and dist directories | |
| cp -r . $out/lib/node_modules/pi-monorepo/ | |
| # Remove broken workspace symlinks that point to non-existent node_modules paths | |
| rm -rf $out/lib/node_modules/pi-monorepo/node_modules/.bin | |
| # Create bin directory | |
| mkdir -p $out/bin | |
| # Create wrapper for pi that includes runtime dependencies | |
| makeWrapper ${pkgs.nodejs_22}/bin/node $out/bin/pi \ | |
| --add-flags "$out/lib/node_modules/pi-monorepo/packages/coding-agent/dist/cli.js" \ | |
| --prefix PATH : ${pkgs.lib.makeBinPath [ | |
| pkgs.ripgrep | |
| pkgs.fd | |
| pkgs.git | |
| ]} | |
| runHook postInstall | |
| ''; | |
| meta = with pkgs.lib; { | |
| description = "An AI coding agent that can read/write files, execute commands, and edit code"; | |
| homepage = "https://github.com/badlogic/pi-mono"; | |
| license = licenses.mit; | |
| maintainers = []; | |
| platforms = platforms.unix; | |
| }; | |
| }; | |
| in { | |
| packages = { | |
| default = pi; | |
| pi = pi; | |
| }; | |
| apps.default = { | |
| type = "app"; | |
| program = "${pi}/bin/pi"; | |
| }; | |
| # Development shell with all tools | |
| devShells.default = pkgs.mkShell { | |
| buildInputs = with pkgs; [ | |
| nodejs_22 | |
| ripgrep | |
| fd | |
| git | |
| ]; | |
| }; | |
| } | |
| ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment