diff --git a/pkgs/by-name/ni/ni/package.nix b/pkgs/by-name/ni/ni/package.nix new file mode 100644 index 000000000000..7c1e15edaf61 --- /dev/null +++ b/pkgs/by-name/ni/ni/package.nix @@ -0,0 +1,66 @@ +{ + lib, + stdenv, + fetchFromGitHub, + nodejs, + pnpm_9, + npmHooks, + versionCheckHook, + nix-update-script, +}: +let + pnpm = pnpm_9; +in +stdenv.mkDerivation (finalAttrs: { + pname = "ni"; + version = "23.3.1"; + + src = fetchFromGitHub { + owner = "antfu-collective"; + repo = "ni"; + tag = "v${finalAttrs.version}"; + hash = "sha256-jkynuN7w0YaIYQLX0KsEQWqrXkhvh3qKSLK63A/7mx8="; + }; + + pnpmDeps = pnpm.fetchDeps { + inherit (finalAttrs) pname version src; + hash = "sha256-gDBjAwut217mdbWyk/dSU4JOkoRbOk4Czlb/lXhWqRU="; + }; + + nativeBuildInputs = [ + nodejs + pnpm.configHook + npmHooks.npmInstallHook + ]; + + buildPhase = '' + runHook preBuild + + pnpm run build + find dist -type f \( -name '*.cjs' -or -name '*.cts' -or -name '*.ts' \) -delete + + runHook postBuild + ''; + + dontNpmPrune = true; + postInstall = '' + rm -rf $out/lib/node_modules/@antfu/ni/node_modules + ''; + + nativeInstallCheckInputs = [ + versionCheckHook + ]; + versionCheckProgramArg = [ "--version" ]; + doInstallCheck = true; + + passthru.updateScript = nix-update-script { }; + + meta = { + description = "Use the right package manager"; + homepage = "https://github.com/antfu-collective/ni"; + changelog = "https://github.com/antfu-collective/ni/releases/tag/v${finalAttrs.version}"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ xiaoxiangmoe ]; + mainProgram = "ni"; + }; +})