From 3962275b5d93040a62d24e77afe21a0314837051 Mon Sep 17 00:00:00 2001 From: Aliaksandr Date: Mon, 25 May 2026 12:15:38 +0300 Subject: [PATCH] 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 --- .../node/fetch-pnpm-deps/default.nix | 45 +++++++------------ .../node/fetch-pnpm-deps/pnpm-config-hook.sh | 8 +--- .../node/fetch-pnpm-deps/serve.nix | 8 +--- 3 files changed, 20 insertions(+), 41 deletions(-) diff --git a/pkgs/build-support/node/fetch-pnpm-deps/default.nix b/pkgs/build-support/node/fetch-pnpm-deps/default.nix index 800b4df62131..a91dfada90e5 100644 --- a/pkgs/build-support/node/fetch-pnpm-deps/default.nix +++ b/pkgs/build-support/node/fetch-pnpm-deps/default.nix @@ -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 ''; diff --git a/pkgs/build-support/node/fetch-pnpm-deps/pnpm-config-hook.sh b/pkgs/build-support/node/fetch-pnpm-deps/pnpm-config-hook.sh index dc732c3822f8..4bf73d805692 100644 --- a/pkgs/build-support/node/fetch-pnpm-deps/pnpm-config-hook.sh +++ b/pkgs/build-support/node/fetch-pnpm-deps/pnpm-config-hook.sh @@ -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" diff --git a/pkgs/build-support/node/fetch-pnpm-deps/serve.nix b/pkgs/build-support/node/fetch-pnpm-deps/serve.nix index 46288e974660..2c3292180d8f 100644 --- a/pkgs/build-support/node/fetch-pnpm-deps/serve.nix +++ b/pkgs/build-support/node/fetch-pnpm-deps/serve.nix @@ -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"