From ae0783dd07d17152795ce8485f59d5f9b8b1813a Mon Sep 17 00:00:00 2001 From: ljxfstorm Date: Sat, 4 Apr 2026 00:29:07 +0800 Subject: [PATCH 1/2] gemini-cli-bin: 0.34.0 -> 0.36.0 Upstream switched from the standalone JS release to a bundle zip, splitting the `gemini.js` into multiple chunks. Migrate to `fetchzip` and move Nix-specific modifications into a loop over chunks in `patchPhase`. --- pkgs/by-name/ge/gemini-cli-bin/package.nix | 52 ++++++++++++++-------- 1 file changed, 34 insertions(+), 18 deletions(-) diff --git a/pkgs/by-name/ge/gemini-cli-bin/package.nix b/pkgs/by-name/ge/gemini-cli-bin/package.nix index 98c0a97b8a20..b805e04eeac4 100644 --- a/pkgs/by-name/ge/gemini-cli-bin/package.nix +++ b/pkgs/by-name/ge/gemini-cli-bin/package.nix @@ -1,7 +1,7 @@ { lib, stdenvNoCC, - fetchurl, + fetchzip, nodejs, sysctl, writableTmpDirAsHomeHook, @@ -11,15 +11,14 @@ }: stdenvNoCC.mkDerivation (finalAttrs: { pname = "gemini-cli-bin"; - version = "0.34.0"; + version = "0.36.0"; - src = fetchurl { - url = "https://github.com/google-gemini/gemini-cli/releases/download/v${finalAttrs.version}/gemini.js"; - hash = "sha256-Qfol6zATjVK6d4gfA6ql3aVwjqRE7NAYqg5YTyEVDHk="; + src = fetchzip { + url = "https://github.com/google-gemini/gemini-cli/releases/download/v${finalAttrs.version}/gemini-cli-bundle.zip"; + hash = "sha256-wu+QZ5roBNY1mwtte+7opKFBRdOCXONW95UEJ7M3gJI="; + stripRoot = false; }; - dontUnpack = true; - strictDeps = true; nativeBuildInputs = [ @@ -31,24 +30,41 @@ stdenvNoCC.mkDerivation (finalAttrs: { ripgrep ]; + patchPhase = '' + runHook prePatch + + # chunk filenames contain unpredictable hashes, use glob to iterate + for chunk in ./chunk-*.js; do + + # disable auto-update + if grep -q 'enableAutoUpdate: {' "$chunk"; then + sed -i '/enableAutoUpdate: {/,/}/ s/default: true/default: false/' "$chunk" + fi + + # use `ripgrep` from `nixpkgs`, more dependencies but prevent downloading incompatible binary on NixOS + # this workaround can be removed once the following upstream issue is resolved: + # https://github.com/google-gemini/gemini-cli/issues/11438 + if grep -q 'await resolveExistingRgPath();' "$chunk"; then + substituteInPlace "$chunk" \ + --replace-fail 'const existingPath = await resolveExistingRgPath();' 'const existingPath = "${lib.getExe ripgrep}";' + fi + + done + + runHook postPatch + ''; + installPhase = '' runHook preInstall - local dest="$out/lib/gemini/gemini.js" - install -Dm644 "$src" "$dest" + local bundleDir="$out/lib/gemini" - # disable auto-update - sed -i '/enableAutoUpdate: {/,/}/ s/default: true/default: false/' "$dest" - - # use `ripgrep` from `nixpkgs`, more dependencies but prevent downloading incompatible binary on NixOS - # this workaround can be removed once the following upstream issue is resolved: - # https://github.com/google-gemini/gemini-cli/issues/11438 - substituteInPlace "$dest" \ - --replace-fail 'const existingPath = await resolveExistingRgPath();' 'const existingPath = "${lib.getExe ripgrep}";' + mkdir -p "$bundleDir" + cp -aT . "$bundleDir" makeWrapper "${lib.getExe nodejs}" "$out/bin/gemini" \ --add-flags "--no-warnings=DEP0040" \ - --add-flags "$dest" + --add-flags "$bundleDir/gemini.js" runHook postInstall ''; From 3dd6028eb3d1869c186a15e24383e8d54afc6bbe Mon Sep 17 00:00:00 2001 From: ljxfstorm Date: Sat, 4 Apr 2026 09:49:13 +0800 Subject: [PATCH 2/2] gemini-cli-bin: drop some outdated workarounds Upstream now reports the correct version and properly distinguishes stable releases from pre-releases. --- pkgs/by-name/ge/gemini-cli-bin/package.nix | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/pkgs/by-name/ge/gemini-cli-bin/package.nix b/pkgs/by-name/ge/gemini-cli-bin/package.nix index b805e04eeac4..9d87c7ac0475 100644 --- a/pkgs/by-name/ge/gemini-cli-bin/package.nix +++ b/pkgs/by-name/ge/gemini-cli-bin/package.nix @@ -76,19 +76,18 @@ stdenvNoCC.mkDerivation (finalAttrs: { ++ lib.optionals (with stdenvNoCC.hostPlatform; isDarwin && isx86_64) [ sysctl ]; - # versionCheckHook cannot be used because the reported version might be incorrect (e.g., 0.6.1 returns 0.6.0). + + # versionCheckHook cannot be used because it assumes the executable is hermetic, + # but we need `nativeInstallCheckInputs` installCheckPhase = '' runHook preInstallCheck - "$out/bin/gemini" -v + "$out/bin/gemini" -v | grep "${finalAttrs.version}" runHook postInstallCheck ''; - passthru.updateScript = nix-update-script { - # Ignore `preview` and `nightly` tags - extraArgs = [ "--version-regex=^v([0-9.]+)$" ]; - }; + passthru.updateScript = nix-update-script { }; meta = { description = "AI agent that brings the power of Gemini directly into your terminal";