Skip to content

Commit

Permalink
pnpm.fetchDeps: ensure consistent permissions after fetching
Browse files Browse the repository at this point in the history
For reasons not yet completely understood, `pnpm` might create
dependency files with inconsistent file permissions.

Since file permissions are stored in the NAR-archive used to derive the
hash of a fixed output derivation, this leads to inconsistencies
depending on where a derivation is built.

Hence, we ensure a consistent file permission scheme:
* All files with `-exec` suffix have 555.
* All other files have 444.
* All folders have 555.

This schema was chosen because it as already upheld in most environments
we tested.
  • Loading branch information
obreitwi committed Dec 1, 2024
1 parent 2c27ab2 commit 8bfd975
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkgs/development/tools/pnpm/fetch-deps/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,18 @@
jq --sort-keys "del(.. | .checkedAt?)" $f | sponge $f
done
# NOTE: For reasons not yet known, pnpm might create files with
# inconsistent permissions, for example inside the ubuntu-24.04
# github actions runner.
# To ensure stable derivations, we need to set permissions
# consistently, namely:
# * All files with `-exec` suffix have 555.
# * All other files have 444.
# * All folders have 555.
find $out -type f -name "*-exec" -print0 | xargs -0 chmod 555
find $out -type f -not -name "*-exec" -print0 | xargs -0 chmod 444
find $out -type d -print0 | xargs -0 chmod 555
runHook postFixup
'';

Expand Down

0 comments on commit 8bfd975

Please sign in to comment.