depot/third_party/nixpkgs/pkgs/by-name/py/pyright/package.nix
Default email bcb2f287e1 Project import generated by Copybara.
GitOrigin-RevId: d603719ec6e294f034936c0d0dc06f689d91b6c3
2024-06-20 20:27:18 +05:30

75 lines
2 KiB
Nix

{ lib, buildNpmPackage, fetchFromGitHub, runCommand, jq }:
let
version = "1.1.367";
src = fetchFromGitHub {
owner = "Microsoft";
repo = "pyright";
rev = "${version}";
hash = "sha256-ILhY6O5B38P5PYdCK1DeuvQzTU5SbhL3F4X0KFne9UM=";
};
patchedPackageJSON = runCommand "package.json" { } ''
${jq}/bin/jq '
.devDependencies |= with_entries(select(.key == "glob" or .key == "jsonc-parser"))
| .scripts = { }
' ${src}/package.json > $out
'';
pyright-root = buildNpmPackage {
pname = "pyright-root";
inherit version src;
npmDepsHash = "sha256-63kUhKrxtJhwGCRBnxBfOFXs2ARCNn+OOGu6+fSJey4=";
dontNpmBuild = true;
postPatch = ''
cp ${patchedPackageJSON} ./package.json
cp ${./package-lock.json} ./package-lock.json
'';
installPhase = ''
runHook preInstall
cp -r . "$out"
runHook postInstall
'';
};
pyright-internal = buildNpmPackage {
pname = "pyright-internal";
inherit version src;
sourceRoot = "${src.name}/packages/pyright-internal";
npmDepsHash = "sha256-MskvUwzlREmTR8qmLlWGxNWVlveIIyHhihigkQ+5seY=";
dontNpmBuild = true;
installPhase = ''
runHook preInstall
cp -r . "$out"
runHook postInstall
'';
};
in
buildNpmPackage rec {
pname = "pyright";
inherit version src;
sourceRoot = "${src.name}/packages/pyright";
npmDepsHash = "sha256-kpqV81iafKWROtdPxLZqi6YVT0WJf82salTFl46Iu24=";
postPatch = ''
chmod +w ../../
ln -s ${pyright-root}/node_modules ../../node_modules
chmod +w ../pyright-internal
ln -s ${pyright-internal}/node_modules ../pyright-internal/node_modules
'';
dontNpmBuild = true;
passthru.updateScript = ./update.sh;
meta = {
changelog = "https://github.com/Microsoft/pyright/releases/tag/${version}";
description = "Type checker for the Python language";
homepage = "https://github.com/Microsoft/pyright";
license = lib.licenses.mit;
mainProgram = "pyright";
maintainers = with lib.maintainers; [ kalekseev ];
};
}