nodejs: corepack wrappers package

This commit is contained in:
Wout Mertens 2022-09-27 10:17:50 +02:00
parent 8acedb7656
commit 724f6bcb77
3 changed files with 41 additions and 0 deletions

View File

@ -217,6 +217,10 @@ $ prefetch-npm-deps package-lock.json
sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
```
### corepack {#javascript-corepack}
This package puts the corepack wrappers for npm, pnpm and yarn in your PATH, and they will honor the `packageManager` setting in the `package.json`.
### node2nix {#javascript-node2nix}
#### Preparation {#javascript-node2nix-preparation}

View File

@ -0,0 +1,28 @@
{ lib, stdenv, nodejs }:
let
inherit (nodejs) version;
in
stdenv.mkDerivation {
name = "corepack-nodejs-${version}";
nativeBuildInputs = [ nodejs ];
unpackPhase = "true";
installPhase = ''
mkdir -p $out/bin
corepack enable --install-directory $out/bin
# Also wrap npm
corepack enable --install-directory $out/bin npm
'';
meta = {
description = "Wrappers for npm, pnpm and yarn via nodejs's corepack";
homepage = "https://nodejs.org";
changelog = "https://github.com/nodejs/node/releases/tag/v${version}";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ wmertens ];
platforms = lib.platforms.linux ++ lib.platforms.darwin;
};
}

View File

@ -10236,6 +10236,8 @@ with pkgs;
nodenv = callPackage ../development/tools/nodenv { };
nodejs = hiPrio nodejs_18;
corepack = hiPrio (callPackage ../development/web/nodejs/corepack.nix {
nodejs = nodejs; });
nodejs-slim = nodejs-slim_18;
@ -10254,13 +10256,20 @@ with pkgs;
nodejs-slim_18 = callPackage ../development/web/nodejs/v18.nix {
enableNpm = false;
};
corepack_18 = hiPrio (callPackage ../development/web/nodejs/corepack.nix
{ nodejs = nodejs_18; });
nodejs_20 = callPackage ../development/web/nodejs/v20.nix { };
nodejs-slim_20 = callPackage ../development/web/nodejs/v20.nix {
enableNpm = false;
};
corepack_20 = hiPrio (callPackage ../development/web/nodejs/corepack.nix
{ nodejs = nodejs_20; });
# Update this when adding the newest nodejs major version!
nodejs_latest = nodejs_20;
nodejs-slim_latest = nodejs-slim_20;
corepack_latest = hiPrio (callPackage ../development/web/nodejs/corepack.nix
{ nodejs = nodejs_latest; });
buildNpmPackage = callPackage ../build-support/node/build-npm-package { };