Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 lib, 3 buildNpmPackage, 4 fetchzip, 5 ripgrep, 6 makeWrapper, 7 testers, 8}: 9 10buildNpmPackage (finalAttrs: { 11 pname = "amp-cli"; 12 version = "0.0.1752566512-ga67426"; 13 14 src = fetchzip { 15 url = "https://registry.npmjs.org/@sourcegraph/amp/-/amp-${finalAttrs.version}.tgz"; 16 hash = "sha256-TgSqpczEFIW6doWzgfPg2y+o+64ntPMbTJ0FVzCGNOg="; 17 }; 18 19 postPatch = '' 20 cp ${./package-lock.json} package-lock.json 21 22 # Create a minimal package.json with just the dependency we need (without devDependencies) 23 cat > package.json <<EOF 24 { 25 "name": "amp-cli", 26 "version": "0.0.0", 27 "license": "UNLICENSED", 28 "dependencies": { 29 "@sourcegraph/amp": "${finalAttrs.version}" 30 }, 31 "bin": { 32 "amp": "./bin/amp-wrapper.js" 33 } 34 } 35 EOF 36 37 # Create wrapper bin directory 38 mkdir -p bin 39 40 # Create a wrapper script that will be installed by npm 41 cat > bin/amp-wrapper.js << EOF 42 #!/usr/bin/env node 43 require('@sourcegraph/amp/dist/amp.js') 44 EOF 45 chmod +x bin/amp-wrapper.js 46 ''; 47 48 npmDepsHash = "sha256-avgj8q1pyepWSt4RFK1+9Fqwtc7Z1Voz2RUYKuViZA0="; 49 50 propagatedBuildInputs = [ 51 ripgrep 52 ]; 53 54 nativeBuildInputs = [ 55 makeWrapper 56 ]; 57 58 npmFlags = [ 59 "--no-audit" 60 "--no-fund" 61 "--ignore-scripts" 62 ]; 63 64 # Disable build and prune steps 65 dontNpmBuild = true; 66 67 postInstall = '' 68 wrapProgram $out/bin/amp \ 69 --prefix PATH : ${lib.makeBinPath [ ripgrep ]} 70 ''; 71 72 passthru.updateScript = ./update.sh; 73 passthru.tests.version = testers.testVersion { 74 package = finalAttrs.finalPackage; 75 command = "HOME=$(mktemp -d) amp --version"; 76 }; 77 78 meta = { 79 description = "CLI for Amp, an agentic coding agent in research preview from Sourcegraph"; 80 homepage = "https://ampcode.com/"; 81 downloadPage = "https://www.npmjs.com/package/@sourcegraph/amp"; 82 license = lib.licenses.unfree; 83 maintainers = with lib.maintainers; [ 84 keegancsmith 85 owickstrom 86 ]; 87 mainProgram = "amp"; 88 }; 89})