nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at devShellTools-shell 74 lines 2.1 kB view raw
1yarnConfigHook() { 2 echo "Executing yarnConfigHook" 3 4 # Use a constant HOME directory 5 export HOME=$(mktemp -d) 6 if [[ -n "$yarnOfflineCache" ]]; then 7 offlineCache="$yarnOfflineCache" 8 fi 9 if [[ -z "$offlineCache" ]]; then 10 echo yarnConfigHook: No yarnOfflineCache or offlineCache were defined\! >&2 11 exit 2 12 fi 13 14 local -r cacheLockfile="$offlineCache/yarn.lock" 15 local -r srcLockfile="$PWD/yarn.lock" 16 17 echo "Validating consistency between $srcLockfile and $cacheLockfile" 18 19 if ! @diff@ "$srcLockfile" "$cacheLockfile"; then 20 # If the diff failed, first double-check that the file exists, so we can 21 # give a friendlier error msg. 22 if ! [ -e "$srcLockfile" ]; then 23 echo 24 echo "ERROR: Missing yarn.lock from src. Expected to find it at: $srcLockfile" 25 echo "Hint: You can copy a vendored yarn.lock file via postPatch." 26 echo 27 28 exit 1 29 fi 30 31 if ! [ -e "$cacheLockfile" ]; then 32 echo 33 echo "ERROR: Missing lockfile from cache. Expected to find it at: $cacheLockfile" 34 echo 35 36 exit 1 37 fi 38 39 echo 40 echo "ERROR: fetchYarnDeps hash is out of date" 41 echo 42 echo "The yarn.lock in src is not the same as the in $offlineCache." 43 echo 44 echo "To fix the issue:" 45 echo '1. Use `lib.fakeHash` as the fetchYarnDeps hash value' 46 echo "2. Build the derivation and wait for it to fail with a hash mismatch" 47 echo "3. Copy the 'got: sha256-' value back into the fetchYarnDeps hash field" 48 echo 49 50 exit 1 51 fi 52 53 yarn config --offline set yarn-offline-mirror "$offlineCache" 54 fixup-yarn-lock yarn.lock 55 yarn install \ 56 --frozen-lockfile \ 57 --force \ 58 --production=false \ 59 --ignore-engines \ 60 --ignore-platform \ 61 --ignore-scripts \ 62 --no-progress \ 63 --non-interactive \ 64 --offline 65 66 # TODO: Check if this is really needed 67 patchShebangs node_modules 68 69 echo "finished yarnConfigHook" 70} 71 72if [[ -z "${dontYarnInstallDeps-}" ]]; then 73 postConfigureHooks+=(yarnConfigHook) 74fi