mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-06-05 21:03:40 +00:00
1.8 KiB
1.8 KiB
npmHooks.npmBuildHook
Hook for building packages that use npm. Can be used in multi-language environments.
Examples
:::{.example #npm-build-hook-example-snippet}
Using npmHooks
{
stdenv,
fetchFromGitHub,
fetchNpmDeps,
npmHooks,
nodejsInstallExecutables,
nodejsInstallManuals,
nodejs,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "some-npm-project";
version = "1.0";
src = fetchFromGitHub {
owner = "JohnNpm";
repo = "SomeProject";
tag = finalAttrs.version;
hash = "...";
};
strictDeps = true;
nativeBuildInputs = [
nodejs
nodejsInstallExecutables
nodejsInstallManuals
npmHooks.npmConfigHook
npmHooks.npmBuildHook
npmHooks.npmInstallHook
];
npmBuildScript = "build";
npmBuildFlags = [
"--prod"
];
npmFlags = [
"--ignore-scripts"
];
npmDeps = fetchNpmDeps {
inherit (finalAttrs) src;
hash = "...";
};
makeWrapperArgs = [
"--set"
"NODE_ENV"
"production"
];
meta = {
description = "npm project";
};
})
:::
Variables controlling npmBuildHook
npmBuildHook Exclusive Variables
npmBuildScript
Controls the script ran to build the npm package within the package.json file.
Required to be set, usually to build, but can vary between packages.
npmBuildFlags
Controls the arguments to the {command}npm run $npmBuildScript command.
dontNpmBuild
Disables npmBuildHook when enabled
Honored Variables
The following variables are honored by the npmBuildHook.