From 34fc9a0b25a25e95746ab264f96338557ba4a426 Mon Sep 17 00:00:00 2001 From: sdedovic Date: Fri, 21 Mar 2025 00:04:12 -0500 Subject: [PATCH 1/2] maintainers: add sdedovic --- maintainers/maintainer-list.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix index 9bc461a0c704..eb523f0fa8ad 100644 --- a/maintainers/maintainer-list.nix +++ b/maintainers/maintainer-list.nix @@ -21415,6 +21415,12 @@ github = "sdaqo"; githubId = 63876564; }; + sdedovic = { + name = "Stevan Dedovic"; + email = "stevan@dedovic.com"; + github = "sdedovic"; + githubId = 599915; + }; sdht0 = { email = "nixpkgs@sdht.in"; github = "sdht0"; From 2f0949c45d38745d066d848da04c4b21c3c69de5 Mon Sep 17 00:00:00 2001 From: sdedovic Date: Wed, 19 Mar 2025 22:47:59 -0500 Subject: [PATCH 2/2] tsx: init at 4.19.3 --- pkgs/by-name/ts/tsx/package.nix | 92 +++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 pkgs/by-name/ts/tsx/package.nix diff --git a/pkgs/by-name/ts/tsx/package.nix b/pkgs/by-name/ts/tsx/package.nix new file mode 100644 index 000000000000..f902d7a7bccd --- /dev/null +++ b/pkgs/by-name/ts/tsx/package.nix @@ -0,0 +1,92 @@ +{ + lib, + stdenv, + fetchFromGitHub, + pnpm_9, + nodejs_22, + versionCheckHook, +}: +stdenv.mkDerivation rec { + pname = "tsx"; + version = "4.19.3"; + + src = fetchFromGitHub { + owner = "privatenumber"; + repo = "tsx"; + tag = "v${version}"; + hash = "sha256-wdv2oqJNc6U0Fyv4jT+0LUcYaDfodHk1vQZGMdyFF/E="; + }; + + pnpmDeps = pnpm_9.fetchDeps { + inherit pname version src; + hash = "sha256-57KDZ9cHb7uqnypC0auIltmYMmIhs4PWyf0HTRWEFiU="; + }; + + nativeBuildInputs = [ + nodejs_22 + pnpm_9.configHook + ]; + + buildInputs = [ + nodejs_22 + ]; + + patchPhase = '' + runHook prePatch + + # by default pnpm builds the docs workspace and this was just + # the easiest way I found to stop that, as pnpmWorkspaces and + # other flags did not work + rm pnpm-workspace.yaml + + # because tsx uses semantic-release, the package.json has a placeholder + # version number. this patches it to match the version of the nix package, + # which in turn is the release version in github. + substituteInPlace package.json --replace-fail "0.0.0-semantic-release" "${version}" + + runHook postPatch + ''; + + buildPhase = '' + runHook preBuild + + npm run build + + # remove devDependencies that are only required to build + # and package the typescript code + pnpm prune --prod + + # Clean up broken symlinks left behind by `pnpm prune` + # https://github.com/pnpm/pnpm/issues/3645 + find node_modules -xtype l -delete + + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + + mkdir -p $out/{bin,lib/tsx} + cp -r {dist,node_modules} $out/lib/tsx + chmod +x $out/lib/tsx/dist/cli.mjs + ln -s $out/lib/tsx/dist/cli.mjs $out/bin/tsx + + runHook postInstall + ''; + + # 8 / 85 tests are failing, I do not know why, while regular usage shows no issues. + doCheck = false; + nativeInstallCheckInputs = [ + versionCheckHook + ]; + doInstallCheck = true; + versionCheckProgramArg = "--version"; + + meta = { + description = "TypeScript Execute (tsx): The easiest way to run TypeScript in Node.js"; + homepage = "https://tsx.is"; + license = lib.licenses.mit; + maintainers = [ lib.maintainers.sdedovic ]; + mainProgram = "tsx"; + }; +}