Skip to content

Commit b25e938

Browse files
authored
pnpm_11: init at 11.1.0 (#505103)
2 parents b921adb + 7d318df commit b25e938

78 files changed

Lines changed: 854 additions & 163 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

doc/languages-frameworks/javascript.section.md

Lines changed: 11 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -305,19 +305,26 @@ This package puts the corepack wrappers for pnpm and yarn in your PATH, and they
305305

306306
### pnpm {#javascript-pnpm}
307307

308-
pnpm is available as the top-level package `pnpm`. Additionally, there are variants pinned to certain major versions, like `pnpm_8`, `pnpm_9` and `pnpm_10`, which support different sets of lock file versions.
308+
pnpm is available as the top-level package `pnpm`. Additionally, there are variants pinned to certain major versions, like `pnpm_8`, `pnpm_9`, `pnpm_10`, `pnpm_10_29_2` and `pnpm_11`, which support different sets of lock file versions.
309309

310310
When packaging an application that includes a `pnpm-lock.yaml`, you need to fetch the pnpm store for that project using a fixed-output-derivation. The function `fetchPnpmDeps` can create this pnpm store derivation. In conjunction, the setup hook `pnpmConfigHook` will prepare the build environment to install the pre-fetched dependencies store. Here is an example for a package that contains `package.json` and a `pnpm-lock.yaml` files using the fetcher and setup hook above:
311311

312312
```nix
313313
{
314314
fetchPnpmDeps,
315315
nodejs,
316-
pnpm,
316+
pnpm_11,
317317
pnpmConfigHook,
318318
stdenv,
319319
}:
320-
320+
let
321+
# It is recommended to pin pnpm to a major version, due to regular breaking changes in the store format
322+
# The latest major version is always available under `pkgs.pnpm`
323+
# Optionally override pnpm to use a custom nodejs version
324+
# Make sure that the same nodejs version is referenced in nativeBuildInputs
325+
# pnpm = pnpm_11.override { nodejs = nodejs_24; };
326+
pnpm = pnpm_11;
327+
in
321328
stdenv.mkDerivation (finalAttrs: {
322329
pname = "foo";
323330
version = "0-unstable-1980-01-01";
@@ -334,54 +341,13 @@ stdenv.mkDerivation (finalAttrs: {
334341
335342
pnpmDeps = fetchPnpmDeps {
336343
inherit (finalAttrs) pname version src;
344+
inherit pnpm;
337345
fetcherVersion = 3;
338346
hash = "...";
339347
};
340348
})
341349
```
342350

343-
It is highly recommended to use a pinned version of pnpm (i.e., `pnpm_9` or `pnpm_10`), to increase future reproducibility. It might also be required to use an older version if the package needs support for a certain lock file version. To do so, you can pass the `pnpm` argument to `fetchPnpmDeps` and override the `pnpm` arg in `pnpmConfigHook`. Here are the changes in the example above to use a pinned pnpm version:
344-
345-
<!-- TODO: Does splicing still work when overriding in nativeBuildInputs here? -->
346-
347-
```diff
348-
{
349-
fetchPnpmDeps,
350-
nodejs,
351-
- pnpm,
352-
+ pnpm_10,
353-
pnpmConfigHook,
354-
stdenv,
355-
}:
356-
+let
357-
+ # Optionally override pnpm to use a custom nodejs version
358-
+ # Make sure that the same nodejs version is referenced in nativeBuildInputs
359-
+ # pnpm = pnpm_10.override { nodejs = nodejs_20; };
360-
+in
361-
stdenv.mkDerivation (finalAttrs: {
362-
pname = "foo";
363-
version = "0-unstable-1980-01-01";
364-
365-
src = {
366-
#...
367-
};
368-
369-
nativeBuildInputs = [
370-
nodejs # in case scripts are run outside of a pnpm call
371-
pnpmConfigHook
372-
- pnpm # At least required by pnpmConfigHook, if not other (custom) phases
373-
+ pnpm_10 # At least required by pnpmConfigHook, if not other (custom) phases
374-
];
375-
376-
pnpmDeps = fetchPnpmDeps {
377-
inherit (finalAttrs) pname version src;
378-
+ pnpm = pnpm_10;
379-
fetcherVersion = 3;
380-
hash = "...";
381-
};
382-
})
383-
```
384-
385351
In case you are patching `package.json` or `pnpm-lock.yaml`, make sure to pass `finalAttrs.patches` to the function as well (i.e., `inherit (finalAttrs) patches`.
386352

387353
`pnpmConfigHook` supports adding additional `pnpm install` flags via `pnpmInstallFlags` which can be set to a Nix string array:

pkgs/applications/editors/vscode/extensions/eamodio.gitlens/default.nix

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
pkgs,
44
stdenv,
55
fetchFromGitHub,
6-
pnpm,
6+
pnpm_10,
77
fetchPnpmDeps,
88
pnpmConfigHook,
99
nodejs,
@@ -12,6 +12,8 @@
1212
}:
1313

1414
let
15+
pnpm = pnpm_10;
16+
1517
vsix = stdenv.mkDerivation (finalAttrs: {
1618
name = "gitlens-${finalAttrs.version}.vsix";
1719
pname = "gitlens-vsix";
@@ -26,6 +28,7 @@ let
2628

2729
pnpmDeps = fetchPnpmDeps {
2830
inherit (finalAttrs) pname version src;
31+
inherit pnpm;
2932
fetcherVersion = 3;
3033
hash = "sha256-Yuxuqr1BiviSw+dGNHLs2jAy8ADlBvRks6Kmy7FmCMw=";
3134
};

pkgs/applications/editors/vscode/extensions/rooveterinaryinc.roo-cline/default.nix

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
lib,
33
stdenvNoCC,
44
fetchFromGitHub,
5-
pnpm,
5+
pnpm_10,
66
fetchPnpmDeps,
77
pnpmConfigHook,
88
nodejs,
@@ -11,6 +11,8 @@
1111
}:
1212

1313
let
14+
pnpm = pnpm_10;
15+
1416
vsix = stdenvNoCC.mkDerivation (finalAttrs: {
1517
name = "roo-code-${finalAttrs.version}.vsix";
1618
pname = "roo-code-vsix";
@@ -25,6 +27,7 @@ let
2527

2628
pnpmDeps = fetchPnpmDeps {
2729
inherit (finalAttrs) pname version src;
30+
inherit pnpm;
2831
fetcherVersion = 3;
2932
hash = "sha256-t2sPuhn8xdk6hGfmViPGG+5TAhtBBOMYNoOb6DlPzws=";
3033
};

pkgs/build-support/node/fetch-pnpm-deps/default.nix

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
cacert,
88
makeSetupHook,
99
pnpm,
10+
pnpm-fixup-state-db,
1011
writableTmpDirAsHomeHook,
1112
yq,
1213
zstd,
@@ -47,6 +48,14 @@ in
4748
};
4849

4950
filterFlags = lib.map (package: "--filter=${package}") pnpmWorkspaces;
51+
52+
pnpm-fixup-state-db' =
53+
if pnpm.nodejs or null != null then
54+
pnpm-fixup-state-db.override {
55+
inherit (pnpm) nodejs;
56+
}
57+
else
58+
pnpm-fixup-state-db;
5059
in
5160
# pnpmWorkspace was deprecated, so throw if it's used.
5261
assert (lib.throwIf (args ? pnpmWorkspace)
@@ -77,6 +86,8 @@ in
7786
jq
7887
moreutils
7988
pnpm # from args
89+
pnpm-fixup-state-db'
90+
writableTmpDirAsHomeHook
8091
yq
8192
zstd
8293
]
@@ -88,14 +99,17 @@ in
8899
installPhase = ''
89100
runHook preInstall
90101
102+
versionAtLeast () {
103+
local cur_version=$1 min_version=$2
104+
printf "%s\0%s" "$min_version" "$cur_version" | sort -zVC
105+
}
106+
91107
lockfileVersion="$(yq -r .lockfileVersion pnpm-lock.yaml)"
92108
if [[ ''${lockfileVersion:0:1} -gt ${lib.versions.major pnpm.version} ]]; then
93109
echo "ERROR: lockfileVersion $lockfileVersion in pnpm-lock.yaml is too new for the provided pnpm version ${lib.versions.major pnpm.version}!"
94110
exit 1
95111
fi
96112
97-
export HOME=$(mktemp -d)
98-
99113
# For fetcherVersion < 3, the pnpm store files are placed directly into $out.
100114
# For fetcherVersion >= 3, it is bundled into a compressed tarball within $out,
101115
# without distributing the uncompressed store files.
@@ -106,19 +120,29 @@ in
106120
storePath=$out
107121
fi
108122
109-
# If the packageManager field in package.json is set to a different pnpm version than what is in nixpkgs,
110-
# any pnpm command would fail in that directory, the following disables this
111-
pushd ..
112-
pnpm config set manage-package-manager-versions false
123+
pushd "$HOME"
124+
pnpmVersion=$(pnpm --version)
125+
126+
if versionAtLeast "$pnpmVersion" "11"; then
127+
# pnpm 11 uses a different mechanism to manage package manager versions
128+
export pnpm_config_pm_on_fail=ignore
129+
130+
# Some packages produce platform dependent outputs. We do not want to cache those in the global store
131+
export pnpm_config_side_effects_cache false
132+
133+
export pnpm_config_update_notifier false
134+
else
135+
pnpm config set manage-package-manager-versions false
136+
pnpm config set side-effects-cache false
137+
pnpm config set update-notifier false
138+
fi
113139
popd
114140
115141
pnpm config set store-dir $storePath
116-
# Some packages produce platform dependent outputs. We do not want to cache those in the global store
117-
pnpm config set side-effects-cache false
118-
# As we pin pnpm versions, we don't really care about updates
119-
pnpm config set update-notifier false
142+
120143
# Run any additional pnpm configuration commands that users provide.
121144
${prePnpmInstall}
145+
122146
# pnpm is going to warn us about using --force
123147
# --force allows us to fetch all dependencies including ones that aren't meant for our host platform
124148
pnpm install \
@@ -141,14 +165,18 @@ in
141165
runHook preFixup
142166
143167
# Remove timestamp and sort the json files
144-
rm -rf $storePath/{v3,v10}/tmp
168+
rm -rf $storePath/{v3,v10,v11}/tmp
145169
for f in $(find $storePath -name "*.json"); do
146170
jq --sort-keys "del(.. | .checkedAt?)" $f | sponge $f
147171
done
148172
173+
if [ -f "$storePath/v11/index.db" ]; then
174+
pnpm-fixup-state-db "$storePath/v11";
175+
fi
176+
149177
# This folder contains symlinks to /build/source which we don't need
150178
# since https://github.com/pnpm/pnpm/releases/tag/v10.27.0
151-
rm -rf $storePath/{v3,v10}/projects
179+
rm -rf $storePath/{v3,v10,v11}/projects
152180
153181
# Ensure consistent permissions
154182
# NOTE: For reasons not yet fully understood, pnpm might create files with

pkgs/build-support/node/fetch-pnpm-deps/pnpm-config-hook.sh

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# shellcheck shell=bash
22

3+
versionAtLeast () {
4+
local cur_version=$1 min_version=$2
5+
printf "%s\0%s" "$min_version" "$cur_version" | sort -zVC
6+
}
7+
38
pnpmConfigHook() {
49
echo "Executing pnpmConfigHook"
510

@@ -17,13 +22,18 @@ pnpmConfigHook() {
1722
exit 1
1823
fi
1924

20-
# If the packageManager field in package.json is set to a different pnpm version than what is in nixpkgs,
21-
# any pnpm command would fail in that directory, the following disables this
22-
pushd $HOME
23-
pnpm config set manage-package-manager-versions false
25+
pushd "$HOME"
26+
pnpmVersion=$(pnpm --version)
27+
28+
if versionAtLeast "$pnpmVersion" "11"; then
29+
# pnpm 11 uses a different mechanism to manage package manager versions
30+
export pnpm_config_pm_on_fail=ignore
31+
else
32+
pnpm config set manage-package-manager-versions false
33+
fi
2434
popd
2535

26-
echo "Found 'pnpm' with version '$(pnpm --version)'"
36+
echo "Found 'pnpm' with version '$pnpmVersion'"
2737

2838
fetcherVersion=$(cat "${pnpmDeps}/.fetcher-version" || echo 1)
2939

@@ -33,7 +43,9 @@ pnpmConfigHook() {
3343

3444
export STORE_PATH=$(mktemp -d)
3545
export npm_config_arch="@npmArch@"
46+
export pnpm_config_arch="@npmArch@"
3647
export npm_config_platform="@npmPlatform@"
48+
export pnpm_config_platform="@npmPlatform@"
3749

3850
if [[ $fetcherVersion -ge 3 ]]; then
3951
tar --zstd -xf "$pnpmDeps/pnpm-store.tar.zst" -C "$STORE_PATH"

pkgs/build-support/node/fetch-pnpm-deps/serve.nix

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
pnpm,
44
pnpmDeps,
55
zstd,
6+
lib,
67
}:
78

89
writeShellApplication {
@@ -41,4 +42,8 @@ writeShellApplication {
4142
pnpm server start \
4243
--store-dir "$storePath"
4344
'';
45+
46+
meta = {
47+
broken = lib.versionAtLeast pnpm.version "11";
48+
};
4449
}

pkgs/by-name/ag/agent-browser/package.nix

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
fetchPnpmDeps,
66
rustPlatform,
77
nodejs,
8-
pnpm,
8+
pnpm_10,
99
pnpmConfigHook,
1010
geist-font,
1111
nix-update-script,
@@ -14,6 +14,8 @@
1414
}:
1515

1616
let
17+
pnpm = pnpm_10;
18+
1719
version = "0.27.0";
1820

1921
src = fetchFromGitHub {
@@ -39,7 +41,7 @@ let
3941

4042
pnpmDeps = fetchPnpmDeps {
4143
pname = "agent-browser-dashboard";
42-
inherit version src;
44+
inherit version src pnpm;
4345
pnpmWorkspaces = [ "dashboard" ];
4446
fetcherVersion = 3;
4547
hash = "sha256-ldxmXpejqVN/xuWcdLYMwNPc1VZ1rdNwRrumy8Is3N4=";

pkgs/by-name/ap/apache-airflow/python-package.nix

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# javascript
88
fetchPnpmDeps,
99
nodejs,
10-
pnpm,
10+
pnpm_10,
1111
pnpmConfigHook,
1212

1313
# python
@@ -97,6 +97,8 @@ let
9797
hash = "sha256-qFgI65wAttERPCHn7ezSdNGB0sclEV7zYIBqaC0Gs4A=";
9898
};
9999

100+
pnpm = pnpm_10;
101+
100102
airflowUi = stdenv.mkDerivation rec {
101103
pname = "airflow-ui-assets";
102104
inherit src version;
@@ -110,7 +112,12 @@ let
110112

111113
pnpmDeps = fetchPnpmDeps {
112114
pname = "airflow-ui";
113-
inherit sourceRoot src version;
115+
inherit
116+
sourceRoot
117+
src
118+
version
119+
pnpm
120+
;
114121
fetcherVersion = 3;
115122
hash = "sha256-zPIql9rP4EkE0Y3ihP4MkWTTYCIDr8d1LpE6vePiNdU=";
116123
};

pkgs/by-name/ap/apache-answer/package.nix

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
fetchFromGitHub,
55
fetchPnpmDeps,
66
pnpmConfigHook,
7-
pnpm,
7+
pnpm_10,
88
nodejs,
99
stdenv,
1010
}:
11-
11+
let
12+
pnpm = pnpm_10;
13+
in
1214
buildGoModule (finalAttrs: {
1315
pname = "apache-answer";
1416
version = "1.7.1";
@@ -28,6 +30,7 @@ buildGoModule (finalAttrs: {
2830

2931
pnpmDeps = fetchPnpmDeps {
3032
inherit (finalAttrs) src version pname;
33+
inherit pnpm;
3134
sourceRoot = "${finalAttrs.src.name}/ui";
3235
fetcherVersion = 3;
3336
hash = "sha256-0Jqe0wig28Vb9y0/tZHDfE49MehNR7kJTpChz616tzU=";

0 commit comments

Comments
 (0)