diff --git a/pkgs/by-name/ge/geminicommit/package.nix b/pkgs/by-name/ge/geminicommit/package.nix index 2b69183918c9..2c83ac9c285a 100644 --- a/pkgs/by-name/ge/geminicommit/package.nix +++ b/pkgs/by-name/ge/geminicommit/package.nix @@ -4,6 +4,7 @@ fetchFromGitHub, installShellFiles, stdenv, + versionCheckHook, }: buildGoModule (finalAttrs: { @@ -26,9 +27,18 @@ buildGoModule (finalAttrs: { postInstall = let cmd = finalAttrs.meta.mainProgram; + goDefaultCmd = finalAttrs.pname; in - lib.optionalString (with stdenv; buildPlatform.canExecute hostPlatform) '' - # `geminicommit` requires write permissions to $HOME for its `config.toml` + # The official github released binary is renamed since v0.4.1, + # see: https://github.com/tfkhdyt/geminicommit/releases/tag/v0.4.1 + # Here we link the old name (which is also the `go build` default name) + # for backward compatibility: + '' + mv $out/bin/${goDefaultCmd} $out/bin/${cmd} + ln -s $out/bin/${cmd} $out/bin/${goDefaultCmd} + '' + + lib.optionalString (with stdenv; buildPlatform.canExecute hostPlatform) '' + # `gmc` requires write permissions to $HOME for its `config.toml` # ... which is automatically initiated on startup export HOME=$(mktemp -d) @@ -39,11 +49,17 @@ buildGoModule (finalAttrs: { done ''; + nativeInstallCheckInputs = [ + versionCheckHook + ]; + + doInstallCheck = true; + meta = { description = "CLI that generates git commit messages with Google Gemini AI"; homepage = "https://github.com/tfkhdyt/geminicommit"; license = lib.licenses.gpl3Only; maintainers = with lib.maintainers; [ bryango ]; - mainProgram = "geminicommit"; + mainProgram = "gmc"; }; })