{ lib, buildGoModule, go_1_26, fetchFromGitHub, unpinGoModVersionHook, versionCheckHook, flake, mkUpdater, }: let versionData = builtins.fromJSON (builtins.readFile ./hashes.json); inherit (versionData) version hash vendorHash; in buildGoModule.override { go = go_1_26; } { pname = "cli-proxy-api"; inherit version vendorHash; src = fetchFromGitHub { owner = "router-for-me"; repo = "CLIProxyAPI"; tag = "v${version}"; inherit hash; }; nativeBuildInputs = [ unpinGoModVersionHook ]; subPackages = [ "cmd/server" ]; ldflags = [ "-s" "-w" "-X main.Version=${version}" "-X main.Commit=nixpkgs" "-X main.BuildDate=1970-01-01T00:00:00Z" ]; postInstall = '' mv $out/bin/server $out/bin/cli-proxy-api ''; doInstallCheck = true; nativeInstallCheckInputs = [ versionCheckHook ]; passthru.category = "Utilities"; passthru.updater = mkUpdater { kind = "github-source"; purl = "pkg:github/router-for-me/CLIProxyAPI"; depHashKey = "vendorHash"; }; meta = with lib; { description = "Unified proxy providing OpenAI/Gemini/Claude/Codex compatible APIs for AI coding CLI tools"; homepage = "https://github.com/router-for-me/CLIProxyAPI"; changelog = "https://github.com/router-for-me/CLIProxyAPI/releases"; license = licenses.mit; sourceProvenance = with lib.sourceTypes; [ fromSource ]; maintainers = with flake.lib.maintainers; [ odysseus0 ]; mainProgram = "cli-proxy-api"; platforms = platforms.all; }; }