diff --git a/doc/languages-frameworks/javascript.section.md b/doc/languages-frameworks/javascript.section.md index 0a2099b0a6b1..fb1dd898c8a2 100644 --- a/doc/languages-frameworks/javascript.section.md +++ b/doc/languages-frameworks/javascript.section.md @@ -217,6 +217,10 @@ $ prefetch-npm-deps package-lock.json sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= ``` +### corepack {#javascript-corepack} + +This package puts the corepack wrappers for pnpm and yarn in your PATH, and they will honor the `packageManager` setting in the `package.json`. + ### node2nix {#javascript-node2nix} #### Preparation {#javascript-node2nix-preparation} diff --git a/pkgs/development/web/nodejs/corepack.nix b/pkgs/development/web/nodejs/corepack.nix new file mode 100644 index 000000000000..c83d3f1645fc --- /dev/null +++ b/pkgs/development/web/nodejs/corepack.nix @@ -0,0 +1,26 @@ +{ lib, stdenv, nodejs }: + +stdenv.mkDerivation { + pname = "corepack-nodejs"; + inherit (nodejs) version; + + nativeBuildInputs = [ nodejs ]; + + dontUnpack = true; + + installPhase = '' + mkdir -p $out/bin + corepack enable --install-directory $out/bin + # Enabling npm caused some crashes - leaving out for now + # corepack enable --install-directory $out/bin npm + ''; + + meta = { + description = "Wrappers for npm, pnpm and Yarn via Node.js Corepack"; + homepage = "https://nodejs.org/api/corepack.html"; + changelog = "https://github.com/nodejs/node/releases/tag/v${nodejs.version}"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ wmertens ]; + platforms = lib.platforms.linux ++ lib.platforms.darwin; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 9cf0a108884c..cc82178c2fbd 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -10236,31 +10236,30 @@ with pkgs; nodenv = callPackage ../development/tools/nodenv { }; nodejs = hiPrio nodejs_18; - nodejs-slim = nodejs-slim_18; + corepack = hiPrio corepack_18; - nodejs_14 = callPackage ../development/web/nodejs/v14.nix { - openssl = openssl_1_1; - }; + nodejs_14 = callPackage ../development/web/nodejs/v14.nix { openssl = openssl_1_1; }; nodejs-slim_14 = callPackage ../development/web/nodejs/v14.nix { openssl = openssl_1_1; enableNpm = false; }; + nodejs_16 = callPackage ../development/web/nodejs/v16.nix { }; - nodejs-slim_16 = callPackage ../development/web/nodejs/v16.nix { - enableNpm = false; - }; + nodejs-slim_16 = callPackage ../development/web/nodejs/v16.nix { enableNpm = false; }; + nodejs_18 = callPackage ../development/web/nodejs/v18.nix { }; - nodejs-slim_18 = callPackage ../development/web/nodejs/v18.nix { - enableNpm = false; - }; + 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; - }; + 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 corepack_20; buildNpmPackage = callPackage ../build-support/node/build-npm-package { };