nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 77 lines 2.3 kB view raw
1{ 2 lib, 3 stdenv, 4 buildNpmPackage, 5 fetchFromGitHub, 6 esbuild, 7 nix-update-script, 8 versionCheckHook, 9 vscode-extensions, 10}: 11let 12 inherit (vscode-extensions.chenglou92.rescript-vscode) rescript-editor-analysis; 13 platformDir = 14 if stdenv.hostPlatform.isLinux then 15 "linux" 16 else if stdenv.hostPlatform.isDarwin then 17 "darwin" 18 else if stdenv.hostPlatform.isFreeBSD then 19 "freebsd" 20 else if stdenv.hostPlatform.isWindows then 21 "win32" 22 else 23 throw "Unsupported system: ${stdenv.system}"; 24in 25buildNpmPackage (finalAttrs: { 26 # These have the same source, and must be the same version. 27 inherit (rescript-editor-analysis) src version; 28 pname = "rescript-language-server"; 29 30 sourceRoot = "${finalAttrs.src.name}/server"; 31 32 npmDepsHash = "sha256-Qi41qDJ0WR0QWw7guhuz1imT51SqI7mORGjNbmZWnio"; 33 34 strictDeps = true; 35 nativeBuildInputs = [ esbuild ]; 36 37 # Tries to do funny things (install all packages for the entire repo) if you don't override it. This is just a copy paste 38 # from the package.json. 39 buildPhase = '' 40 runHook preBuild 41 42 # https://github.com/rescript-lang/rescript-vscode/blob/1.62.0/package.json#L252 43 esbuild src/cli.ts --bundle --sourcemap --outfile=out/cli.js --format=cjs --platform=node --loader:.node=file --minify 44 45 runHook postBuild 46 ''; 47 48 postInstall = '' 49 DIR="$out/lib/node_modules/@rescript/language-server/analysis_binaries/${platformDir}" 50 51 mkdir -p "$DIR" 52 ln -s ${lib.getExe rescript-editor-analysis} "$DIR"/rescript-editor-analysis 53 ''; 54 55 nativeInstallCheckInputs = [ 56 versionCheckHook 57 ]; 58 doInstallCheck = true; 59 60 passthru.updateScript = nix-update-script { 61 extraArgs = [ 62 "--version-regex" 63 "([0-9]+\\.[0-9]+\\.[0-9]+)" 64 ]; 65 }; 66 67 meta = { 68 description = "ReScript Language Server"; 69 homepage = "https://github.com/rescript-lang/rescript-vscode/tree/${finalAttrs.version}/server"; 70 changelog = "https://github.com/rescript-lang/rescript-vscode/releases/tag/${finalAttrs.version}"; 71 mainProgram = "rescript-language-server"; 72 license = lib.licenses.mit; 73 # https://github.com/rescript-lang/rescript-vscode/blob/1.62.0/CONTRIBUTING.md?plain=1#L186 74 platforms = with lib.platforms; linux ++ darwin ++ windows ++ freebsd; 75 maintainers = with lib.maintainers; [ RossSmyth ]; 76 }; 77})