lol
1{
2 lib,
3 stdenvNoCC,
4 fetchurl,
5 nodejs,
6 writableTmpDirAsHomeHook,
7 nix-update-script,
8}:
9stdenvNoCC.mkDerivation (finalAttrs: {
10 pname = "gemini-cli-bin";
11 version = "0.6.1";
12
13 src = fetchurl {
14 url = "https://github.com/google-gemini/gemini-cli/releases/download/v${finalAttrs.version}/gemini.js";
15 hash = "sha256-gTd+uw5geR7W87BOiE6YmDDJ4AiFlYxbuLE2GWgg0kw=";
16 };
17
18 phases = [
19 "installPhase"
20 "fixupPhase"
21 "installCheckPhase"
22 ];
23
24 strictDeps = true;
25
26 buildInputs = [ nodejs ];
27
28 installPhase = ''
29 runHook preInstall
30
31 install -D "$src" "$out/bin/gemini"
32
33 runHook postInstall
34 '';
35
36 doInstallCheck = true;
37 nativeInstallCheckInputs = [
38 writableTmpDirAsHomeHook
39 ];
40 # versionCheckHook cannot be used because the reported version might be incorrect (e.g., 0.6.1 returns 0.6.0).
41 installCheckPhase = ''
42 runHook preInstallCheck
43
44 "$out/bin/gemini" -v
45
46 runHook postInstallCheck
47 '';
48
49 passthru.updateScript = nix-update-script {
50 # Ignore `preview` and `nightly` tags
51 extraArgs = [ "--version-regex=^v([0-9.]+)$" ];
52 };
53
54 meta = {
55 description = "AI agent that brings the power of Gemini directly into your terminal";
56 homepage = "https://github.com/google-gemini/gemini-cli";
57 license = lib.licenses.asl20;
58 maintainers = with lib.maintainers; [ ljxfstorm ];
59 mainProgram = "gemini";
60 platforms = lib.platforms.linux ++ lib.platforms.darwin;
61 sourceProvenance = [ lib.sourceTypes.binaryBytecode ];
62 priority = 10;
63 };
64})