104 lines
2.9 KiB
Nix
104 lines
2.9 KiB
Nix
{
|
|
stdenvNoCC,
|
|
lib,
|
|
fetchurl,
|
|
autoPatchelfHook,
|
|
gzip,
|
|
makeWrapper,
|
|
ripgrep,
|
|
versionCheckHook,
|
|
writableTmpDirAsHomeHook,
|
|
cctools,
|
|
darwin,
|
|
rcodesign,
|
|
}:
|
|
|
|
let
|
|
platforms = {
|
|
# Upstream also publishes linux-x64, which is optimized for AVX2. Use the
|
|
# baseline build for nixpkgs so the x86_64-linux package works on all
|
|
# supported x86_64 CPUs instead of depending on the build user's CPU flags.
|
|
x86_64-linux = "linux-x64-baseline";
|
|
aarch64-linux = "linux-arm64";
|
|
aarch64-darwin = "darwin-arm64";
|
|
};
|
|
|
|
in
|
|
stdenvNoCC.mkDerivation (finalAttrs: {
|
|
pname = "amp-cli";
|
|
version = "0.0.1784391370-g49c6a1";
|
|
|
|
src = finalAttrs.passthru.sources.${stdenvNoCC.hostPlatform.system};
|
|
|
|
nativeBuildInputs = [
|
|
gzip
|
|
makeWrapper
|
|
]
|
|
++ lib.optionals stdenvNoCC.hostPlatform.isLinux [ autoPatchelfHook ];
|
|
strictDeps = true;
|
|
|
|
dontUnpack = true;
|
|
dontStrip = true;
|
|
dontFixup = !stdenvNoCC.hostPlatform.isLinux;
|
|
|
|
installPhase = ''
|
|
runHook preInstall
|
|
|
|
mkdir -p $out/bin $out/libexec/amp-cli
|
|
gunzip -c $src > $out/libexec/amp-cli/amp
|
|
chmod +x $out/libexec/amp-cli/amp
|
|
|
|
makeWrapper $out/libexec/amp-cli/amp $out/bin/amp \
|
|
--set AMP_SKIP_UPDATE_CHECK 1 \
|
|
--prefix PATH : ${lib.makeBinPath [ ripgrep ]}
|
|
|
|
runHook postInstall
|
|
'';
|
|
|
|
postInstall = lib.optionalString stdenvNoCC.hostPlatform.isDarwin ''
|
|
'${lib.getExe' cctools "${cctools.targetPrefix}install_name_tool"}' $out/libexec/amp-cli/amp \
|
|
-change /usr/lib/libicucore.A.dylib '${lib.getLib darwin.ICU}/lib/libicucore.A.dylib'
|
|
'${lib.getExe rcodesign}' sign --code-signature-flags linker-signed $out/libexec/amp-cli/amp
|
|
'';
|
|
|
|
doInstallCheck = stdenvNoCC.buildPlatform.canExecute stdenvNoCC.hostPlatform;
|
|
nativeInstallCheckInputs = [
|
|
writableTmpDirAsHomeHook
|
|
versionCheckHook
|
|
];
|
|
versionCheckProgram = "${placeholder "out"}/bin/amp";
|
|
versionCheckProgramArg = "--version";
|
|
versionCheckKeepEnvironment = [ "HOME" ];
|
|
|
|
passthru = {
|
|
sources = lib.mapAttrs (
|
|
system': platform:
|
|
fetchurl {
|
|
url = "https://static.ampcode.com/cli/${finalAttrs.version}/amp-${platform}.gz";
|
|
hash =
|
|
{
|
|
x86_64-linux = "sha256-x7p8BIQbu/ylyCkE63NZQUYfOn5nzwvwqXRWYbW4Q8w=";
|
|
aarch64-linux = "sha256-X2xQzlu2VfucXii92mFWsp1Ab8blBORtT/BE0kcZi6g=";
|
|
aarch64-darwin = "sha256-8jj4+dtc54eaFHVlCYKdX9F3s/qrCVICgi5Dyi+n3cg=";
|
|
}
|
|
.${system'};
|
|
}
|
|
) platforms;
|
|
updateScript = ./update.sh;
|
|
};
|
|
|
|
meta = {
|
|
description = "CLI for Amp, an agentic coding agent in research preview from Sourcegraph";
|
|
homepage = "https://ampcode.com/";
|
|
downloadPage = "https://ampcode.com/install";
|
|
license = lib.licenses.unfree;
|
|
maintainers = with lib.maintainers; [
|
|
keegancsmith
|
|
burmudar
|
|
];
|
|
mainProgram = "amp";
|
|
platforms = builtins.attrNames platforms;
|
|
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
|
|
};
|
|
})
|