An unofficial flake for an official Kotlin LSP server
at main 3.3 kB view raw
1{ 2 description = "An unofficial Nix wrapper for official Kotlin LSP"; 3 4 inputs = { 5 nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; 6 flake-parts.url = "github:hercules-ci/flake-parts"; 7 }; 8 9 outputs = inputs@{ self, nixpkgs, flake-parts, ... }: 10 flake-parts.lib.mkFlake { inherit inputs; } { 11 systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; 12 13 perSystem = { config, self', inputs', pkgs, system, ... }: 14 let 15 sources = { 16 "x86_64-linux" = { 17 url = "https://download-cdn.jetbrains.com/kotlin-lsp/261.13587.0/kotlin-lsp-261.13587.0-linux-x64.zip"; 18 hash = "sha256-EweSqy30NJuxvlJup78O+e+JOkzvUdb6DshqAy1j9jE="; 19 }; 20 "aarch64-linux" = { 21 url = "https://download-cdn.jetbrains.com/kotlin-lsp/261.13587.0/kotlin-lsp-261.13587.0-linux-aarch64.zip"; 22 hash = "sha256-MhHEYHBctaDH9JVkN/guDCG1if9Bip1aP3n+JkvHCvA="; 23 }; 24 "x86_64-darwin" = { 25 url = "https://download-cdn.jetbrains.com/kotlin-lsp/261.13587.0/kotlin-lsp-261.13587.0-mac-x64.zip"; 26 hash = "sha256-zMuUcahT1IiCT1NTrMCIzUNM0U6U3zaBkJtbGrzF7I8="; 27 }; 28 "aarch64-darwin" = { 29 url = "https://download-cdn.jetbrains.com/kotlin-lsp/261.13587.0/kotlin-lsp-261.13587.0-mac-aarch64.zip"; 30 hash = "sha256-zwlzVt3KYN0OXKr6sI9XSijXSbTImomSTGRGa+3zCK8="; 31 }; 32 }; 33 34 srcData = sources.${system} or (throw "Unsupported system: ${system}"); 35 in 36 { 37 formatter = pkgs.nixpkgs-fmt; 38 39 packages.default = pkgs.stdenv.mkDerivation { 40 pname = "kotlin-lsp"; 41 version = "261.13587.0"; 42 43 src = pkgs.fetchzip { 44 url = srcData.url; 45 hash = srcData.hash; 46 stripRoot = false; 47 }; 48 49 nativeBuildInputs = [ 50 pkgs.makeWrapper 51 ] ++ pkgs.lib.optionals pkgs.stdenv.isLinux [ 52 pkgs.autoPatchelfHook 53 ]; 54 55 buildInputs = pkgs.lib.optionals pkgs.stdenv.isLinux [ 56 pkgs.stdenv.cc.cc.lib 57 pkgs.zlib 58 pkgs.libxtst 59 pkgs.alsa-lib 60 pkgs.freetype 61 pkgs.wayland 62 pkgs.libxrender 63 ]; 64 65 installPhase = '' 66 runHook preInstall 67 68 mkdir -p $out/bin $out/libexec 69 cp -r ./* $out/libexec 70 chmod -R u+w $out/libexec 71 chmod +x $out/libexec/kotlin-lsp.sh 72 chmod +x $out/libexec/jre/bin/java 73 patchShebangs $out/libexec/kotlin-lsp.sh 74 makeWrapper $out/libexec/kotlin-lsp.sh $out/bin/kotlin-lsp 75 76 runHook postInstall 77 ''; 78 79 meta = { 80 description = "Kotlin Language Server by JetBrains"; 81 homepage = "https://github.com/Kotlin/kotlin-lsp"; 82 license = pkgs.lib.licenses.asl20; 83 platforms = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; 84 }; 85 }; 86 }; 87 88 flake = { 89 overlays.default = final: prev: { 90 kotlin-lsp = self.packages.${prev.system}.default; 91 }; 92 }; 93 }; 94}