about summary refs log tree commit diff
path: root/pkgs/by-name/py/pyright/package.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/by-name/py/pyright/package.nix')
-rw-r--r--pkgs/by-name/py/pyright/package.nix75
1 files changed, 75 insertions, 0 deletions
diff --git a/pkgs/by-name/py/pyright/package.nix b/pkgs/by-name/py/pyright/package.nix
new file mode 100644
index 0000000000000..3e264bc20e819
--- /dev/null
+++ b/pkgs/by-name/py/pyright/package.nix
@@ -0,0 +1,75 @@
+{ lib, buildNpmPackage, fetchFromGitHub, runCommand, jq }:
+
+let
+  version = "1.1.359";
+
+  src = fetchFromGitHub {
+    owner = "Microsoft";
+    repo = "pyright";
+    rev = "${version}";
+    hash = "sha256-gqMAfmYjYO6D9sRu+uJv4yJ/+csioFAwsUPBDF29VDs=";
+  };
+
+  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-p2KamNFJ3sJHmJm0MEPhI8L/8zAVzfc9NYy24rAdFcQ=";
+    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-U7WdMIYg9U4fJ8YtDruMzloRS2BQAa2QWExle9uwPbU=";
+
+  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 ];
+  };
+}