nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 84 lines 2.7 kB view raw
1{ 2 lib, 3 stdenvNoCC, 4 fetchurl, 5 nodejs, 6 sysctl, 7 writableTmpDirAsHomeHook, 8 nix-update-script, 9 ripgrep, 10}: 11stdenvNoCC.mkDerivation (finalAttrs: { 12 pname = "gemini-cli-bin"; 13 version = "0.25.0"; 14 15 src = fetchurl { 16 url = "https://github.com/google-gemini/gemini-cli/releases/download/v${finalAttrs.version}/gemini.js"; 17 hash = "sha256-7Co3DPZs/ZtdLfhZnOcpdFFQPnyeLkvxTZG+tv+FbBQ="; 18 }; 19 20 dontUnpack = true; 21 22 strictDeps = true; 23 24 buildInputs = [ 25 nodejs 26 ripgrep 27 ]; 28 29 installPhase = '' 30 runHook preInstall 31 32 install -D "$src" "$out/bin/gemini" 33 34 # ideal method to disable auto-update 35 sed -i '/disableautoupdate: {/,/}/ s/default: false/default: true/' "$out/bin/gemini" 36 37 # disable auto-update for real because the default value in settingsschema isn't cleanly applied 38 # https://github.com/google-gemini/gemini-cli/issues/13569 39 substituteInPlace $out/bin/gemini \ 40 --replace-fail "settings.merged.general?.disableUpdateNag" "(settings.merged.general?.disableUpdateNag ?? true)" \ 41 --replace-fail "settings.merged.general?.disableAutoUpdate ?? false" "settings.merged.general?.disableAutoUpdate ?? true" \ 42 --replace-fail "settings.merged.general?.disableAutoUpdate" "(settings.merged.general?.disableAutoUpdate ?? true)" 43 44 # use `ripgrep` from `nixpkgs`, more dependencies but prevent downloading incompatible binary on NixOS 45 # this workaround can be removed once the following upstream issue is resolved: 46 # https://github.com/google-gemini/gemini-cli/issues/11438 47 substituteInPlace $out/bin/gemini \ 48 --replace-fail 'const existingPath = await resolveExistingRgPath();' 'const existingPath = "${lib.getExe ripgrep}";' 49 50 runHook postInstall 51 ''; 52 53 doInstallCheck = true; 54 nativeInstallCheckInputs = [ 55 writableTmpDirAsHomeHook 56 ] 57 ++ lib.optionals (with stdenvNoCC.hostPlatform; isDarwin && isx86_64) [ 58 sysctl 59 ]; 60 # versionCheckHook cannot be used because the reported version might be incorrect (e.g., 0.6.1 returns 0.6.0). 61 installCheckPhase = '' 62 runHook preInstallCheck 63 64 "$out/bin/gemini" -v 65 66 runHook postInstallCheck 67 ''; 68 69 passthru.updateScript = nix-update-script { 70 # Ignore `preview` and `nightly` tags 71 extraArgs = [ "--version-regex=^v([0-9.]+)$" ]; 72 }; 73 74 meta = { 75 description = "AI agent that brings the power of Gemini directly into your terminal"; 76 homepage = "https://github.com/google-gemini/gemini-cli"; 77 license = lib.licenses.asl20; 78 maintainers = with lib.maintainers; [ ljxfstorm ]; 79 mainProgram = "gemini"; 80 platforms = lib.platforms.linux ++ lib.platforms.darwin; 81 sourceProvenance = [ lib.sourceTypes.binaryBytecode ]; 82 priority = 10; 83 }; 84})