Commit e4013455 authored by Benjamin Sparks's avatar Benjamin Sparks
Browse files

tsgolint: add updateScript

Required removing `applyPatches`, so patching directives have been inlined
parent 369f2b91
Loading
Loading
Loading
Loading
+36 −30
Original line number Diff line number Diff line
@@ -3,15 +3,14 @@
  buildGoModule,
  fetchFromGitHub,
  findutils,
  applyPatches,
  go,
  nix-update-script,
}:

buildGoModule (finalAttrs: {
  pname = "tsgolint";
  version = "0.10.1";

  src = applyPatches rec {
  src = fetchFromGitHub {
    owner = "oxc-project";
    repo = "tsgolint";
@@ -19,29 +18,32 @@ buildGoModule (finalAttrs: {
    hash = "sha256-6cDQjYVNfujIh3s+9pNCfqUEtfdvgx66oZoENqpJ7jE=";
    fetchSubmodules = true;
  };

  nativeBuildInputs = [ findutils ];

  prePatch = ''
      cd typescript-go
    pushd typescript-go
  '';

  # These patches are applied to the typescript-go submodule in justfile's "init" target upstream.
  patches = [
      (src + "/patches/0001-Parallel-readDirectory-visitor.patch")
      (src + "/patches/0002-Adapt-project-service-for-single-run-mode.patch")
      (src + "/patches/0003-patch-expose-more-functions-via-the-shim-with-type-f.patch")
      (src + "/patches/0004-feat-improve-panic-message-for-extracting-TS-extensi.patch")
      (src + "/patches/0005-fix-early-return-from-invalid-tsconfig-for-better-er.patch")
    (finalAttrs.src + "/patches/0001-Parallel-readDirectory-visitor.patch")
    (finalAttrs.src + "/patches/0002-Adapt-project-service-for-single-run-mode.patch")
    (finalAttrs.src + "/patches/0003-patch-expose-more-functions-via-the-shim-with-type-f.patch")
    (finalAttrs.src + "/patches/0004-feat-improve-panic-message-for-extracting-TS-extensi.patch")
    (finalAttrs.src + "/patches/0005-fix-early-return-from-invalid-tsconfig-for-better-er.patch")
  ];

  postPatch =
    # We don't want to build with go.work, so we add the replacement to
    # the local module to the go.mod instead.
    postPatch = ''
      cd ..
    ''
      popd
      ${lib.getExe go} mod edit --replace=github.com/microsoft/typescript-go=./typescript-go
    '';
  };

  nativeBuildInputs = [ findutils ];

    ''
    +
    # From justfile's "init" target upstream.
  postPatch = ''
    ''
      rm go.work{,.sum}
      mkdir -p internal/collections && find ./typescript-go/internal/collections -type f ! -name '*_test.go' -exec cp {} internal/collections/ \;
    '';
@@ -53,6 +55,10 @@ buildGoModule (finalAttrs: {

  env.GOEXPERIMENT = "greenteagc";

  passthru = {
    updateScript = nix-update-script { };
  };

  meta = {
    description = "Type aware linting for oxlint";
    homepage = "https://github.com/oxc-project/tsgolint";