From eb3b90ac41f00d310db14bfafaa4aa4492a988d8 Mon Sep 17 00:00:00 2001 From: happysalada Date: Sun, 28 Jan 2024 15:04:52 -0500 Subject: [PATCH] helix-gpt: init at 0.15 --- pkgs/by-name/he/helix-gpt/package.nix | 63 +++++++++++++++++++++++++++ pkgs/by-name/he/helix-gpt/pin.json | 6 +++ 2 files changed, 69 insertions(+) create mode 100644 pkgs/by-name/he/helix-gpt/package.nix create mode 100644 pkgs/by-name/he/helix-gpt/pin.json diff --git a/pkgs/by-name/he/helix-gpt/package.nix b/pkgs/by-name/he/helix-gpt/package.nix new file mode 100644 index 000000000000..4c39a7b357cf --- /dev/null +++ b/pkgs/by-name/he/helix-gpt/package.nix @@ -0,0 +1,63 @@ +{ stdenv, lib, fetchFromGitHub, bun, makeBinaryWrapper }: +let + pin = lib.importJSON ./pin.json; + src = fetchFromGitHub { + owner = "leona"; + repo = "helix-gpt"; + rev = pin.version; + hash = pin.srcHash; + }; + node_modules = stdenv.mkDerivation { + pname = "helix-gpt-node_modules"; + inherit src; + version = pin.version; + impureEnvVars = lib.fetchers.proxyImpureEnvVars + ++ [ "GIT_PROXY_COMMAND" "SOCKS_SERVER" ]; + nativeBuildInputs = [ bun ]; + dontConfigure = true; + buildPhase = '' + bun install --no-progress --frozen-lockfile + ''; + installPhase = '' + mkdir -p $out/node_modules + + cp -R ./node_modules $out + ''; + outputHash = pin."${stdenv.system}"; + outputHashAlgo = "sha256"; + outputHashMode = "recursive"; + }; +in +stdenv.mkDerivation { + pname = "helix-gpt"; + version = pin.version; + inherit src; + nativeBuildInputs = [ makeBinaryWrapper ]; + + dontConfigure = true; + dontBuild = true; + + installPhase = '' + runHook preInstall + + mkdir -p $out/bin + + ln -s ${node_modules}/node_modules $out + cp -R ./* $out + + # bun is referenced naked in the package.json generated script + makeBinaryWrapper ${bun}/bin/bun $out/bin/helix-gpt \ + --prefix PATH : ${lib.makeBinPath [ bun ]} \ + --add-flags "run --prefer-offline --no-install --cwd $out ./src/app.ts" + + runHook postInstall + ''; + + meta = with lib; { + homepage = "https://github.com/leona/helix-gpt"; + description = "Code completion LSP for Helix with support for Copilot + OpenAI"; + maintainers = with maintainers; [ happysalada ]; + license = with licenses; [ mit ]; + platforms = [ "x86_64-linux" "x86_64-darwin" ]; + }; +} diff --git a/pkgs/by-name/he/helix-gpt/pin.json b/pkgs/by-name/he/helix-gpt/pin.json new file mode 100644 index 000000000000..ab2a52bb0968 --- /dev/null +++ b/pkgs/by-name/he/helix-gpt/pin.json @@ -0,0 +1,6 @@ +{ + "version": "0.15", + "srcHash": "sha256-95NnV//DesXQB1ttvOylu1DAnmRcvTUpZzK1NTZtuVE=", + "x86_64-linux": "sha256-h6wGkOfSbB8Rwm7eFvcowDdH1RdS6eFaxgf+SdYvYt8=", + "x86_64-darwin": "sha256-45RFY4Kqt5ooMOY75oJcSUZdkERzpyIMQkni4NJ/s1Y=" +}