3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/build-support/node/build-npm-package/hooks/default.nix
Winter 009a234bdd prefetch-npm-deps: repack hosted git deps
Previously, we stored the tarballs from the hosted Git providers directly in the cache. However, as we've seen with `fetchFromGitHub` etc, these files may change subtly.

Given this, this commit repacks the dependencies before storing them in the cache.
2022-11-21 15:00:08 -05:00

36 lines
1 KiB
Nix

{ lib, makeSetupHook, nodejs, srcOnly, buildPackages, makeWrapper }:
{
npmConfigHook = makeSetupHook
{
name = "npm-config-hook";
substitutions = {
nodeSrc = srcOnly nodejs;
# Specify `diff`, `jq`, and `prefetch-npm-deps` by abspath to ensure that the user's build
# inputs do not cause us to find the wrong binaries.
diff = "${buildPackages.diffutils}/bin/diff";
jq = "${buildPackages.jq}/bin/jq";
prefetchNpmDeps = "${buildPackages.prefetch-npm-deps}/bin/prefetch-npm-deps";
nodeVersion = nodejs.version;
nodeVersionMajor = lib.versions.major nodejs.version;
};
} ./npm-config-hook.sh;
npmBuildHook = makeSetupHook
{
name = "npm-build-hook";
} ./npm-build-hook.sh;
npmInstallHook = makeSetupHook
{
name = "npm-install-hook";
deps = [ makeWrapper ];
substitutions = {
hostNode = "${nodejs}/bin/node";
jq = "${buildPackages.jq}/bin/jq";
};
} ./npm-install-hook.sh;
}