mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-06-05 21:03:40 +00:00
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
This commit is contained in:
@@ -111,15 +111,10 @@ in
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# For fetcherVersion < 3, the pnpm store files are placed directly into $out.
|
||||
# For fetcherVersion >= 3, it is bundled into a compressed tarball within $out,
|
||||
# The pnpm store is bundled into a compressed tarball within $out,
|
||||
# without distributing the uncompressed store files.
|
||||
if [[ ${toString fetcherVersion} -ge 3 ]]; then
|
||||
mkdir $out
|
||||
storePath=$(mktemp -d)
|
||||
else
|
||||
storePath=$out
|
||||
fi
|
||||
mkdir $out
|
||||
storePath=$(mktemp -d)
|
||||
|
||||
pushd "$HOME"
|
||||
pnpmVersion=$(pnpm --version)
|
||||
@@ -158,10 +153,8 @@ in
|
||||
--registry="$NIX_NPM_REGISTRY" \
|
||||
--frozen-lockfile
|
||||
|
||||
# Store newer fetcherVersion in case pnpmConfigHook also needs it
|
||||
if [[ ${toString fetcherVersion} -gt 1 ]]; then
|
||||
echo ${toString fetcherVersion} > $out/.fetcher-version
|
||||
fi
|
||||
# Record the fetcherVersion in the output for introspection.
|
||||
echo ${toString fetcherVersion} > $out/.fetcher-version
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
@@ -201,24 +194,20 @@ in
|
||||
# * All folders have 555.
|
||||
# See https://github.com/NixOS/nixpkgs/pull/350063
|
||||
# See https://github.com/NixOS/nixpkgs/issues/422889
|
||||
if [[ ${toString fetcherVersion} -ge 2 ]]; then
|
||||
find $storePath -type f -name "*-exec" -print0 | xargs --no-run-if-empty -0 chmod 555
|
||||
find $storePath -type f -not -name "*-exec" -print0 | xargs --no-run-if-empty -0 chmod 444
|
||||
find $storePath -type d -print0 | xargs --no-run-if-empty -0 chmod 555
|
||||
fi
|
||||
find $storePath -type f -name "*-exec" -print0 | xargs --no-run-if-empty -0 chmod 555
|
||||
find $storePath -type f -not -name "*-exec" -print0 | xargs --no-run-if-empty -0 chmod 444
|
||||
find $storePath -type d -print0 | xargs --no-run-if-empty -0 chmod 555
|
||||
|
||||
if [[ ${toString fetcherVersion} -ge 3 ]]; then
|
||||
(
|
||||
cd $storePath
|
||||
(
|
||||
cd $storePath
|
||||
|
||||
# Build a reproducible tarball, per instructions at https://reproducible-builds.org/docs/archives/
|
||||
tar --sort=name \
|
||||
--mtime="@$SOURCE_DATE_EPOCH" \
|
||||
--owner=0 --group=0 --numeric-owner \
|
||||
--pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime \
|
||||
--zstd -cf $out/pnpm-store.tar.zst .
|
||||
)
|
||||
fi
|
||||
# Build a reproducible tarball, per instructions at https://reproducible-builds.org/docs/archives/
|
||||
tar --sort=name \
|
||||
--mtime="@$SOURCE_DATE_EPOCH" \
|
||||
--owner=0 --group=0 --numeric-owner \
|
||||
--pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime \
|
||||
--zstd -cf $out/pnpm-store.tar.zst .
|
||||
)
|
||||
|
||||
runHook postFixup
|
||||
'';
|
||||
|
||||
@@ -40,7 +40,7 @@ pnpmConfigHook() {
|
||||
|
||||
echo "Found 'pnpm' with version '$pnpmVersion'"
|
||||
|
||||
fetcherVersion=$(cat "${pnpmDeps}/.fetcher-version" || echo 1)
|
||||
fetcherVersion=$(cat "${pnpmDeps}/.fetcher-version")
|
||||
|
||||
echo "Using fetcherVersion: $fetcherVersion"
|
||||
|
||||
@@ -52,11 +52,7 @@ pnpmConfigHook() {
|
||||
export npm_config_platform="@npmPlatform@"
|
||||
export pnpm_config_platform="@npmPlatform@"
|
||||
|
||||
if [[ $fetcherVersion -ge 3 ]]; then
|
||||
tar --zstd -xf "$pnpmDeps/pnpm-store.tar.zst" -C "$STORE_PATH"
|
||||
else
|
||||
cp -Tr "$pnpmDeps" "$STORE_PATH"
|
||||
fi
|
||||
tar --zstd -xf "$pnpmDeps/pnpm-store.tar.zst" -C "$STORE_PATH"
|
||||
|
||||
chmod -R +w "$STORE_PATH"
|
||||
|
||||
|
||||
@@ -17,8 +17,6 @@ writeShellApplication {
|
||||
text = ''
|
||||
storePath=$(mktemp -d)
|
||||
|
||||
fetcherVersion=$(cat "${pnpmDeps}/.fetcher-version" || echo 1)
|
||||
|
||||
clean() {
|
||||
echo "Cleaning up temporary store at '$storePath'..."
|
||||
|
||||
@@ -27,11 +25,7 @@ writeShellApplication {
|
||||
|
||||
echo "Copying pnpm store '${pnpmDeps}' to temporary store..."
|
||||
|
||||
if [[ $fetcherVersion -ge 3 ]]; then
|
||||
tar --zstd -xf "${pnpmDeps}/pnpm-store.tar.zst" -C "$storePath"
|
||||
else
|
||||
cp -Tr "${pnpmDeps}" "$storePath"
|
||||
fi
|
||||
tar --zstd -xf "${pnpmDeps}/pnpm-store.tar.zst" -C "$storePath"
|
||||
|
||||
chmod -R +w "$storePath"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user