nixpkgs/pkgs/by-name/am/amp-cli/package.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

90 lines
2 KiB
Nix
Raw Normal View History

2025-05-07 09:17:30 +03:00
{
lib,
buildNpmPackage,
fetchzip,
ripgrep,
makeWrapper,
testers,
2025-05-07 09:17:30 +03:00
}:
buildNpmPackage (finalAttrs: {
2025-05-07 09:17:30 +03:00
pname = "amp-cli";
version = "0.0.1748865683-g71e54e";
2025-05-07 09:17:30 +03:00
src = fetchzip {
url = "https://registry.npmjs.org/@sourcegraph/amp/-/amp-${finalAttrs.version}.tgz";
hash = "sha256-kkQKjw1SzDjV8/206i+NUyxeDhZ/35My9gyXRe/U7I8=";
2025-05-07 09:17:30 +03:00
};
postPatch = ''
cp ${./package-lock.json} package-lock.json
# Create a minimal package.json with just the dependency we need (without devDependencies)
cat > package.json <<EOF
{
"name": "amp-cli",
"version": "0.0.0",
"license": "UNLICENSED",
"dependencies": {
"@sourcegraph/amp": "${finalAttrs.version}"
2025-05-07 09:17:30 +03:00
},
"bin": {
"amp": "./bin/amp-wrapper.js"
}
}
EOF
# Create wrapper bin directory
mkdir -p bin
# Create a wrapper script that will be installed by npm
cat > bin/amp-wrapper.js << EOF
#!/usr/bin/env node
require('@sourcegraph/amp/dist/amp.js')
EOF
chmod +x bin/amp-wrapper.js
'';
npmDepsHash = "sha256-yeZ5UCVUCbVjpYTYYN5mI6eCkShtnCKxumjpb5GRCws=";
2025-05-07 09:17:30 +03:00
propagatedBuildInputs = [
ripgrep
];
nativeBuildInputs = [
makeWrapper
];
npmFlags = [
"--no-audit"
"--no-fund"
"--ignore-scripts"
];
# Disable build and prune steps
dontNpmBuild = true;
postInstall = ''
wrapProgram $out/bin/amp \
--prefix PATH : ${lib.makeBinPath [ ripgrep ]}
'';
passthru.updateScript = ./update.sh;
passthru.tests.version = testers.testVersion {
package = finalAttrs.finalPackage;
command = "HOME=$(mktemp -d) amp --version";
};
2025-05-07 09:17:30 +03:00
meta = {
description = "CLI for Amp, an agentic coding agent in research preview from Sourcegraph";
homepage = "https://ampcode.com/";
2025-05-07 09:17:30 +03:00
downloadPage = "https://www.npmjs.com/package/@sourcegraph/amp";
license = lib.licenses.unfree;
maintainers = with lib.maintainers; [
keegancsmith
owickstrom
2025-05-07 09:17:30 +03:00
];
mainProgram = "amp";
};
})