1{
2 stdenv,
3 lib,
4 fetchurl,
5 gzip,
6 autoPatchelfHook,
7 versionCheckHook,
8}:
9let
10
11 inherit (stdenv.hostPlatform) system;
12 throwSystem = throw "Unsupported system: ${system}";
13
14 plat =
15 {
16 x86_64-linux = "linux_x64";
17 aarch64-linux = "linux_arm";
18 x86_64-darwin = "macos_x64";
19 aarch64-darwin = "macos_arm";
20
21 }
22 .${system} or throwSystem;
23
24 hash =
25 {
26 x86_64-linux = "sha256-noZVrLvkiHP2H3+zWlgqRpKIFxdQzhjl/2XjRpuVYhs=";
27 aarch64-linux = "sha256-bznlEnBZqF3Vfkt8y9XCgQ5O0yxzlGw9HAoByblZ2A4=";
28 x86_64-darwin = "sha256-LIbFX5WUlWw+wF3Sj+v+2zDn2xzvDlW8AO/TJsvDa6c=";
29 aarch64-darwin = "sha256-ANS9FFwrgmRhknpNija9DhO2Znj/RAJhq2GUMZiau6o=";
30 }
31 .${system} or throwSystem;
32
33 bin = "$out/bin/codeium_language_server";
34
35in
36stdenv.mkDerivation (finalAttrs: {
37 pname = "codeium";
38 version = "1.46.3";
39 src = fetchurl {
40 name = "${finalAttrs.pname}-${finalAttrs.version}.gz";
41 url = "https://github.com/Exafunction/codeium/releases/download/language-server-v${finalAttrs.version}/language_server_${plat}.gz";
42 inherit hash;
43 };
44
45 nativeBuildInputs = [ gzip ] ++ lib.optionals stdenv.hostPlatform.isLinux [ autoPatchelfHook ];
46
47 dontUnpack = true;
48 dontConfigure = true;
49 dontBuild = true;
50
51 installPhase = ''
52 runHook preInstall
53 mkdir -p $out/bin
54 gzip -dc $src > ${bin}
55 chmod +x ${bin}
56 runHook postInstall
57 '';
58
59 nativeInstallCheckInputs = [
60 versionCheckHook
61 ];
62 versionCheckProgram = "${placeholder "out"}/bin/codeium_language_server";
63 versionCheckProgramArg = "--version";
64 doInstallCheck = true;
65
66 passthru.updateScript = ./update.sh;
67
68 meta = rec {
69 description = "Codeium language server";
70 longDescription = ''
71 Codeium proprietary language server, patched for Nix(OS) compatibility.
72 bin/language_server_x must be symlinked into the plugin directory, replacing the existing binary.
73 For example:
74 ```shell
75 ln -s "$(which codeium_language_server)" /home/a/.local/share/JetBrains/Rider2023.1/codeium/662505c9b23342478d971f66a530cd102ae35df7/language_server_linux_x64
76 ```
77 '';
78 homepage = "https://codeium.com/";
79 downloadPage = homepage;
80 changelog = homepage;
81 license = lib.licenses.unfree;
82 maintainers = with lib.maintainers; [ anpin ];
83 mainProgram = "codeium_language_server";
84 platforms = [
85 "aarch64-darwin"
86 "aarch64-linux"
87 "x86_64-linux"
88 "x86_64-darwin"
89 ];
90 sourceProvenance = [ lib.sourceTypes.binaryNativeCode ];
91 };
92})