Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 lib, 3 stdenv, 4 buildNpmPackage, 5 fetchFromGitHub, 6 esbuild, 7 nix-update-script, 8 versionCheckHook, 9 rescript-editor-analysis, 10}: 11let 12 platformDir = 13 if stdenv.hostPlatform.isLinux then 14 "linux" 15 else if stdenv.hostPlatform.isDarwin then 16 "darwin" 17 else if stdenv.hostPlatform.isFreeBSD then 18 "freebsd" 19 else if stdenv.hostPlatform.isWindows then 20 "win32" 21 else 22 throw "Unsupported system: ${stdenv.system}"; 23in 24buildNpmPackage (finalAttrs: { 25 # These have the same source, and must be the same version. 26 inherit (rescript-editor-analysis) src version; 27 pname = "rescript-language-server"; 28 29 sourceRoot = "${finalAttrs.src.name}/server"; 30 31 npmDepsHash = "sha256-Qi41qDJ0WR0QWw7guhuz1imT51SqI7mORGjNbmZWnio"; 32 33 strictDeps = true; 34 nativeBuildInputs = [ esbuild ]; 35 36 # Tries to do funny things (install all packages for the entire repo) if you don't override it. This is just a copy paste 37 # from the package.json. 38 buildPhase = '' 39 runHook preBuild 40 41 # https://github.com/rescript-lang/rescript-vscode/blob/1.62.0/package.json#L252 42 esbuild src/cli.ts --bundle --sourcemap --outfile=out/cli.js --format=cjs --platform=node --loader:.node=file --minify 43 44 runHook postBuild 45 ''; 46 47 postInstall = '' 48 DIR="$out/lib/node_modules/@rescript/language-server/analysis_binaries/${platformDir}" 49 50 mkdir -p "$DIR" 51 ln -s ${lib.getExe rescript-editor-analysis} "$DIR"/rescript-editor-analysis 52 ''; 53 54 nativeInstallCheckInputs = [ 55 versionCheckHook 56 ]; 57 versionCheckProgramArg = "--version"; 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})