Files
nixpkgs/pkgs/build-support/node/fetch-pnpm-deps/serve.nix
Aliaksandr 3962275b5d fetchPnpmDeps,pnpmConfigHook: remove dead fetcherVersion < 3 infrastructure
With fetcherVersion = 1 and 2 removed, the minimum supported version is 3,
so every store is a reproducible tarball with consistent permissions. Drop
the now-unreachable `fetcherVersion < 3` branches:

- always bundle the store into pnpm-store.tar.zst (drop the direct-to-$out path)
- always write $out/.fetcher-version (drop the `> 1` guard)
- always normalise permissions (drop the `>= 2` guard)
- always extract the tarball in pnpmConfigHook and serve.nix (drop the cp
  fallback and the `|| echo 1` default)

The `>= 4` SQLite-dump guard is kept, since v3 and v4 still differ. Output
for existing v3/v4 derivations is byte-identical, so no hashes change.

Assisted-by: claude-code with claude-opus-4-7[1m]-xhigh
2026-05-31 23:50:22 +03:00

44 lines
725 B
Nix

{
writeShellApplication,
pnpm,
pnpmDeps,
zstd,
lib,
}:
writeShellApplication {
name = "serve-pnpm-store";
runtimeInputs = [
pnpm
zstd
];
text = ''
storePath=$(mktemp -d)
clean() {
echo "Cleaning up temporary store at '$storePath'..."
rm -rf "$storePath"
}
echo "Copying pnpm store '${pnpmDeps}' to temporary store..."
tar --zstd -xf "${pnpmDeps}/pnpm-store.tar.zst" -C "$storePath"
chmod -R +w "$storePath"
echo "Run 'pnpm install --store-dir \"$storePath\"' to install packages from this store."
trap clean EXIT
pnpm server start \
--store-dir "$storePath"
'';
meta = {
broken = lib.versionAtLeast pnpm.version "11";
};
}