codeium: init at 1.2.104

authored by Pavel Anpin and committed by Matthieu Coudron b24f9836 493a816d

+104
+69
pkgs/by-name/co/codeium/package.nix
··· 1 + { stdenv, lib, fetchurl, gzip, autoPatchelfHook }: 2 + let 3 + 4 + inherit (stdenv.hostPlatform) system; 5 + throwSystem = throw "Unsupported system: ${system}"; 6 + 7 + plat = { 8 + x86_64-linux = "linux_x64"; 9 + aarch64-linux = "linux_arm"; 10 + x86_64-darwin = "macos_x64"; 11 + aarch64-darwin = "macos_arm"; 12 + 13 + }.${system} or throwSystem; 14 + 15 + hash = { 16 + x86_64-linux = "sha256-9EGoJ5DoGgVfbhCDeTvn1D7misJEj9jPwuiOK7z95Ts="; 17 + aarch64-linux = "sha256-lO0YOSiO8AUrkbV+3Uyvg6p3bdAcTze3La2g5IcK1f0="; 18 + x86_64-darwin = "sha256-WjvC3pt8Gd4q+BzrOhyGeYwZIbv2m5O3pSXe1N7Najw="; 19 + aarch64-darwin = "sha256-IRm5m/Jaf4pmAzx+MXwmHLejo6Gv2OL56R1IEr/NlZU="; 20 + }.${system} or throwSystem; 21 + 22 + bin = "$out/bin/codeium_language_server"; 23 + 24 + in 25 + stdenv.mkDerivation (finalAttrs: { 26 + pname = "codeium"; 27 + version = "1.2.104"; 28 + src = fetchurl { 29 + name = "${finalAttrs.pname}-${finalAttrs.version}.gz"; 30 + url = "https://github.com/Exafunction/codeium/releases/download/language-server-v${finalAttrs.version}/language_server_${plat}.gz"; 31 + inherit hash; 32 + }; 33 + 34 + nativeBuildInputs = [ gzip ] ++ lib.optionals stdenv.isLinux [ autoPatchelfHook ]; 35 + 36 + dontUnpack = true; 37 + dontConfigure = true; 38 + dontBuild = true; 39 + 40 + installPhase = '' 41 + runHook preInstall 42 + mkdir -p $out/bin 43 + gzip -dc $src > ${bin} 44 + chmod +x ${bin} 45 + runHook postInstall 46 + ''; 47 + 48 + passthru.updateScript = ./update.sh; 49 + 50 + meta = rec { 51 + description = "Codeium language server"; 52 + longDescription = '' 53 + Codeium proprietary language server, patched for Nix(OS) compatibility. 54 + bin/language_server_x must be symlinked into the plugin directory, replacing the existing binary. 55 + For example: 56 + ```shell 57 + ln -s "$(which codeium_language_server)" /home/a/.local/share/JetBrains/Rider2023.1/codeium/662505c9b23342478d971f66a530cd102ae35df7/language_server_linux_x64 58 + ``` 59 + ''; 60 + homepage = "https://codeium.com/"; 61 + downloadPage = homepage; 62 + changelog = homepage; 63 + license = lib.licenses.unfree; 64 + maintainers = with lib.maintainers; [ anpin ]; 65 + mainProgram = "codeium"; 66 + platforms = [ "aarch64-darwin" "aarch64-linux" "x86_64-linux" "x86_64-darwin" ]; 67 + sourceProvenance = [ lib.sourceTypes.binaryNativeCode ]; 68 + }; 69 + })
+35
pkgs/by-name/co/codeium/update.sh
··· 1 + #!/usr/bin/env nix-shell 2 + #!nix-shell -i bash -p curl gnused gawk nix-prefetch jq 3 + 4 + set -euo pipefail 5 + 6 + ROOT="$(dirname "$(readlink -f "$0")")" 7 + NIX_DRV="$ROOT/package.nix" 8 + if [ ! -f "$NIX_DRV" ]; then 9 + echo "ERROR: cannot find package.nix in $ROOT" 10 + exit 1 11 + fi 12 + 13 + fetch_arch() { 14 + VER="$1"; ARCH="$2" 15 + URL="https://github.com/Exafunction/codeium/releases/download/language-server-v${VER}/language_server_${ARCH}.gz" 16 + nix-hash --to-sri --type sha256 "$(nix-prefetch-url --type sha256 "$URL")" 17 + } 18 + 19 + replace_hash() { 20 + sed -i "s#$1 = \"sha256-.\{44\}\"#$1 = \"$2\"#" "$NIX_DRV" 21 + } 22 + 23 + CODEIUM_VER=$(curl -s "https://api.github.com/repos/Exafunction/codeium/releases/latest" | jq -r .tag_name | grep -oP '\d+\.\d+\.\d+' ) 24 + 25 + CODEIUM_LINUX_X64_HASH=$(fetch_arch "$CODEIUM_VER" "linux_x64") 26 + CODEIUM_LINUX_AARCH64_HASH=$(fetch_arch "$CODEIUM_VER" "linux_arm") 27 + CODEIUM_DARWIN_X64_HASH=$(fetch_arch "$CODEIUM_VER" "macos_x64") 28 + CODEIUM_DARWIN_AARCH64_HASH=$(fetch_arch "$CODEIUM_VER" "macos_arm") 29 + 30 + sed -i "s/version = \".*\"/version = \"$CODEIUM_VER\"/" "$NIX_DRV" 31 + 32 + replace_hash "x86_64-linux" "$CODEIUM_LINUX_X64_HASH" 33 + replace_hash "aarch64-linux" "$CODEIUM_LINUX_AARCH64_HASH" 34 + replace_hash "x86_64-darwin" "$CODEIUM_DARWIN_X64_HASH" 35 + replace_hash "aarch64-darwin" "$CODEIUM_DARWIN_AARCH64_HASH"