Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 82 lines 2.1 kB view raw
1{ 2 lib, 3 buildNpmPackage, 4 fetchFromGitHub, 5 runCommand, 6 jq, 7}: 8 9let 10 version = "1.1.402"; 11 12 src = fetchFromGitHub { 13 owner = "Microsoft"; 14 repo = "pyright"; 15 tag = version; 16 hash = "sha256-gB3psPkWVHUrXGQuuqMzy64Ir7hIRpMZ4dkZqusa1mo="; 17 }; 18 19 patchedPackageJSON = runCommand "package.json" { } '' 20 ${jq}/bin/jq ' 21 .devDependencies |= with_entries(select(.key == "glob" or .key == "jsonc-parser")) 22 | .scripts = { } 23 ' ${src}/package.json > $out 24 ''; 25 26 pyright-root = buildNpmPackage { 27 pname = "pyright-root"; 28 inherit version src; 29 sourceRoot = "${src.name}"; # required for update.sh script 30 npmDepsHash = "sha256-1OrUBARwNvT8pTH66W7GAKG8B5fX8/6jtOOYVU6IgSw="; 31 dontNpmBuild = true; 32 postPatch = '' 33 cp ${patchedPackageJSON} ./package.json 34 cp ${./package-lock.json} ./package-lock.json 35 ''; 36 installPhase = '' 37 runHook preInstall 38 cp -r . "$out" 39 runHook postInstall 40 ''; 41 }; 42 43 pyright-internal = buildNpmPackage { 44 pname = "pyright-internal"; 45 inherit version src; 46 sourceRoot = "${src.name}/packages/pyright-internal"; 47 npmDepsHash = "sha256-3eFxGufA41RwuLrwy6Y4Q25mTbfDjm1Ddo2XOwL9lAk="; 48 dontNpmBuild = true; 49 installPhase = '' 50 runHook preInstall 51 cp -r . "$out" 52 runHook postInstall 53 ''; 54 }; 55in 56buildNpmPackage rec { 57 pname = "pyright"; 58 inherit version src; 59 60 sourceRoot = "${src.name}/packages/pyright"; 61 npmDepsHash = "sha256-HxvVBnvM0ocwc1ck0YEj5q5ea4bAfRmftZauJrnhHck="; 62 63 postPatch = '' 64 chmod +w ../../ 65 ln -s ${pyright-root}/node_modules ../../node_modules 66 chmod +w ../pyright-internal 67 ln -s ${pyright-internal}/node_modules ../pyright-internal/node_modules 68 ''; 69 70 dontNpmBuild = true; 71 72 passthru.updateScript = ./update.sh; 73 74 meta = { 75 changelog = "https://github.com/Microsoft/pyright/releases/tag/${src.tag}"; 76 description = "Type checker for the Python language"; 77 homepage = "https://github.com/Microsoft/pyright"; 78 license = lib.licenses.mit; 79 mainProgram = "pyright"; 80 maintainers = with lib.maintainers; [ kalekseev ]; 81 }; 82}