This commit is contained in:
		
							
								
								
									
										5
									
								
								pkgs/by-name/cl/claude-code-acp/info.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								pkgs/by-name/cl/claude-code-acp/info.json
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,5 @@ | |||||||
|  | { | ||||||
|  |   "version": "0.6.7", | ||||||
|  |   "srcHash": "sha256-v32Q02ALWw6Upd4rrHGZH7Vt25+xSnKJCNGJob/irgM=", | ||||||
|  |   "npmDepsHash": "sha256-oUAHkB4EPuo8YCxi9Y/Lc8cipjJQ05o51MpdUsCjiiQ=" | ||||||
|  | } | ||||||
							
								
								
									
										36
									
								
								pkgs/by-name/cl/claude-code-acp/package.nix
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								pkgs/by-name/cl/claude-code-acp/package.nix
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,36 @@ | |||||||
|  | { | ||||||
|  |   lib, | ||||||
|  |   buildNpmPackage, | ||||||
|  |   fetchFromGitHub, | ||||||
|  | }: | ||||||
|  | let | ||||||
|  |   info = lib.importJSON ./info.json; | ||||||
|  | in | ||||||
|  | buildNpmPackage { | ||||||
|  |   pname = "claude-code-acp"; | ||||||
|  |   version = info.version; | ||||||
|  |  | ||||||
|  |   src = fetchFromGitHub { | ||||||
|  |     owner = "zed-industries"; | ||||||
|  |     repo = "claude-code-acp"; | ||||||
|  |     rev = "v${info.version}"; | ||||||
|  |     hash = info.srcHash; | ||||||
|  |   }; | ||||||
|  |  | ||||||
|  |   npmDepsHash = info.npmDepsHash; | ||||||
|  |  | ||||||
|  |   # The package uses TypeScript and builds before publishing | ||||||
|  |   npmBuildScript = "build"; | ||||||
|  |  | ||||||
|  |   passthru = { | ||||||
|  |     updateScript = ./update.mjs; | ||||||
|  |   }; | ||||||
|  |  | ||||||
|  |   meta = { | ||||||
|  |     description = "Use Claude Code from any ACP client such as Zed"; | ||||||
|  |     homepage = "https://github.com/zed-industries/claude-code-acp"; | ||||||
|  |     license = lib.licenses.asl20; | ||||||
|  |     maintainers = with lib.maintainers; [ ]; | ||||||
|  |     mainProgram = "claude-code-acp"; | ||||||
|  |   }; | ||||||
|  | } | ||||||
							
								
								
									
										77
									
								
								pkgs/by-name/cl/claude-code-acp/update.mjs
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										77
									
								
								pkgs/by-name/cl/claude-code-acp/update.mjs
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,77 @@ | |||||||
|  | #! /usr/bin/env nix-shell | ||||||
|  | /* | ||||||
|  | #! nix-shell -i zx  -p nix-prefetch-github -p zx | ||||||
|  | */ | ||||||
|  |  | ||||||
|  | import { readFileSync, writeFileSync } from "fs"; | ||||||
|  | import { dirname, join } from "path"; | ||||||
|  | import { fileURLToPath } from "url"; | ||||||
|  |  | ||||||
|  | const __filename = fileURLToPath(import.meta.url); | ||||||
|  | const __dirname = dirname(__filename); | ||||||
|  |  | ||||||
|  | // GitHub API endpoint for latest release | ||||||
|  | const GITHUB_API = "https://api.github.com/repos/zed-industries/claude-code-acp/releases/latest"; | ||||||
|  |  | ||||||
|  | // Read current info.json | ||||||
|  | const infoPath = join(__dirname, "info.json"); | ||||||
|  | const currentInfo = JSON.parse(readFileSync(infoPath, "utf-8")); | ||||||
|  |  | ||||||
|  | console.log(`Current version: ${currentInfo.version}`); | ||||||
|  |  | ||||||
|  | // Fetch latest release from GitHub | ||||||
|  | console.log("Fetching latest release from GitHub..."); | ||||||
|  | const response = await fetch(GITHUB_API); | ||||||
|  | const release = await response.json(); | ||||||
|  |  | ||||||
|  | const latestVersion = release.tag_name.replace(/^v/, ""); // Remove 'v' prefix | ||||||
|  | console.log(`Latest version: ${latestVersion}`); | ||||||
|  |  | ||||||
|  | if (currentInfo.version === latestVersion) { | ||||||
|  |   console.log("Already up to date!"); | ||||||
|  |   process.exit(0); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Update version | ||||||
|  | currentInfo.version = latestVersion; | ||||||
|  |  | ||||||
|  | // Prefetch source hash | ||||||
|  | console.log("Prefetching source hash..."); | ||||||
|  | const srcHashOutput = await $`nix-prefetch-github zed-industries claude-code-acp --rev v${latestVersion}`; | ||||||
|  | const srcPrefetch = JSON.parse(srcHashOutput.stdout); | ||||||
|  | currentInfo.srcHash = srcPrefetch.hash; | ||||||
|  |  | ||||||
|  | console.log(`Source hash: ${currentInfo.srcHash}`); | ||||||
|  |  | ||||||
|  | // Write temporary info.json to get npmDepsHash | ||||||
|  | writeFileSync(infoPath, JSON.stringify(currentInfo, null, 2) + "\n"); | ||||||
|  |  | ||||||
|  | // Prefetch npm dependencies hash | ||||||
|  | console.log("Prefetching npm dependencies hash..."); | ||||||
|  | try { | ||||||
|  |   // This will fail with the expected hash in the error message | ||||||
|  |   await $`nix build .#claude-code-acp`; | ||||||
|  |  | ||||||
|  | } catch (error) { | ||||||
|  |   // Extract hash from error message | ||||||
|  |   const errorOutput = error.stderr; | ||||||
|  |   const hashMatch = errorOutput.match(/got:\s+(sha256-[A-Za-z0-9+/=]+)/); | ||||||
|  |  | ||||||
|  |   if (hashMatch) { | ||||||
|  |     currentInfo.npmDepsHash = hashMatch[1]; | ||||||
|  |     console.log(`npm deps hash: ${currentInfo.npmDepsHash}`); | ||||||
|  |   } else { | ||||||
|  |     console.error("Failed to extract npmDepsHash from build output"); | ||||||
|  |     console.error("You may need to update it manually by running:"); | ||||||
|  |     console.error(`  nix-build -A claude-code-acp`); | ||||||
|  |     console.error("and copying the hash from the error message"); | ||||||
|  |   } | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Write final info.json | ||||||
|  | writeFileSync(infoPath, JSON.stringify(currentInfo, null, 2) + "\n"); | ||||||
|  |  | ||||||
|  | console.log("\nUpdate complete!"); | ||||||
|  | console.log(`Version: ${currentInfo.version}`); | ||||||
|  | console.log(`Source hash: ${currentInfo.srcHash}`); | ||||||
|  | console.log(`npm deps hash: ${currentInfo.npmDepsHash}`); | ||||||
		Reference in New Issue
	
	Block a user