pnpm.fetchDeps: introduce versioning
This commit is contained in:
parent
dd2290ee7f
commit
fd61e1c200
@ -444,6 +444,7 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
pnpmDeps = pnpm.fetchDeps {
|
||||
inherit (finalAttrs) pname version src;
|
||||
hash = "...";
|
||||
fetcherVersion = 1;
|
||||
};
|
||||
})
|
||||
```
|
||||
@ -558,6 +559,40 @@ set `prePnpmInstall` to the right commands to run. For example:
|
||||
|
||||
In this example, `prePnpmInstall` will be run by both `pnpm.configHook` and by the `pnpm.fetchDeps` builder.
|
||||
|
||||
#### PNPM `fetcherVersion` {#javascript-pnpm-fetcherVersion}
|
||||
|
||||
This is the version of the output of `pnpm.fetchDeps`, if you haven't set it already, you can use `1` with your current hash:
|
||||
|
||||
```nix
|
||||
{
|
||||
# ...
|
||||
pnpmDeps = pnpm.fetchDeps {
|
||||
# ...
|
||||
hash = "..."; # you can use your already set hash here
|
||||
fetcherVersion = 1;
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
After upgrading to a newer `fetcherVersion`, you need to regenerate the hash:
|
||||
|
||||
```nix
|
||||
{
|
||||
# ...
|
||||
pnpmDeps = pnpm.fetchDeps {
|
||||
# ...
|
||||
hash = "..."; # clear this hash and generate a new one
|
||||
fetcherVersion = 2;
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
This variable ensures that we can make changes to the output of `pnpm.fetchDeps` without breaking existing hashes.
|
||||
Changes can include workarounds or bug fixes to existing PNPM issues.
|
||||
|
||||
##### Version history {#javascript-pnpm-fetcherVersion-versionHistory}
|
||||
|
||||
- 1: Initial version, nothing special
|
||||
|
||||
### Yarn {#javascript-yarn}
|
||||
|
||||
|
@ -3347,6 +3347,12 @@
|
||||
"javascript-pnpm-extraCommands": [
|
||||
"index.html#javascript-pnpm-extraCommands"
|
||||
],
|
||||
"javascript-pnpm-fetcherVersion": [
|
||||
"index.html#javascript-pnpm-fetcherVersion"
|
||||
],
|
||||
"javascript-pnpm-fetcherVersion-versionHistory": [
|
||||
"index.html#javascript-pnpm-fetcherVersion-versionHistory"
|
||||
],
|
||||
"javascript-yarn": [
|
||||
"index.html#javascript-yarn"
|
||||
],
|
||||
|
@ -29,6 +29,7 @@ stdenvNoCC.mkDerivation (finalAttrs: {
|
||||
pnpmWorkspaces
|
||||
;
|
||||
hash = "sha256-NvyqPv5OKgZi3hW98Da8LhsYatmrzrPX8kLOfLr+BrI=";
|
||||
fetcherVersion = 1;
|
||||
};
|
||||
|
||||
nativeBuildInputs = [
|
||||
|
@ -22,6 +22,7 @@ in
|
||||
pnpmWorkspaces ? [ ],
|
||||
prePnpmInstall ? "",
|
||||
pnpmInstallFlags ? [ ],
|
||||
fetcherVersion ? 1,
|
||||
...
|
||||
}@args:
|
||||
let
|
||||
@ -96,6 +97,11 @@ in
|
||||
--registry="$NIX_NPM_REGISTRY" \
|
||||
--frozen-lockfile
|
||||
|
||||
# Store newer fetcherVersion in case pnpm.configHook also needs it
|
||||
if [[ ${toString fetcherVersion} -gt 1 ]]; then
|
||||
echo ${toString fetcherVersion} > $out/.fetcher-version
|
||||
fi
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
|
@ -12,6 +12,13 @@ pnpmConfigHook() {
|
||||
exit 1
|
||||
fi
|
||||
|
||||
fetcherVersion=1
|
||||
if [[ -e "${pnpmDeps}/.fetcher-version" ]]; then
|
||||
fetcherVersion=$(cat "${pnpmDeps}/.fetcher-version")
|
||||
fi
|
||||
|
||||
echo "Using fetcherVersion: $fetcherVersion"
|
||||
|
||||
echo "Configuring pnpm store"
|
||||
|
||||
export HOME=$(mktemp -d)
|
||||
|
Loading…
x
Reference in New Issue
Block a user