2022-11-21 17:40:18 +00:00
|
|
|
{ lib, stdenv, fetchNpmDeps, npmHooks, nodejs }:
|
|
|
|
|
|
|
|
{ name ? "${args.pname}-${args.version}"
|
|
|
|
, src ? null
|
|
|
|
, srcs ? null
|
|
|
|
, sourceRoot ? null
|
2022-11-27 09:42:12 +00:00
|
|
|
, prePatch ? ""
|
2022-11-21 17:40:18 +00:00
|
|
|
, patches ? [ ]
|
2022-11-27 09:42:12 +00:00
|
|
|
, postPatch ? ""
|
2022-11-21 17:40:18 +00:00
|
|
|
, nativeBuildInputs ? [ ]
|
|
|
|
, buildInputs ? [ ]
|
|
|
|
# The output hash of the dependencies for this project.
|
|
|
|
# Can be calculated in advance with prefetch-npm-deps.
|
|
|
|
, npmDepsHash ? ""
|
2023-04-29 16:46:19 +00:00
|
|
|
# Whether to force the usage of Git dependencies that have install scripts, but not a lockfile.
|
|
|
|
# Use with care.
|
|
|
|
, forceGitDeps ? false
|
2022-11-21 17:40:18 +00:00
|
|
|
# Whether to make the cache writable prior to installing dependencies.
|
|
|
|
# Don't set this unless npm tries to write to the cache directory, as it can slow down the build.
|
|
|
|
, makeCacheWritable ? false
|
|
|
|
# The script to run to build the project.
|
|
|
|
, npmBuildScript ? "build"
|
|
|
|
# Flags to pass to all npm commands.
|
|
|
|
, npmFlags ? [ ]
|
2023-07-15 17:15:38 +00:00
|
|
|
# Flags to pass to `npm ci`.
|
2022-11-21 17:40:18 +00:00
|
|
|
, npmInstallFlags ? [ ]
|
|
|
|
# Flags to pass to `npm rebuild`.
|
|
|
|
, npmRebuildFlags ? [ ]
|
|
|
|
# Flags to pass to `npm run ${npmBuildScript}`.
|
|
|
|
, npmBuildFlags ? [ ]
|
|
|
|
# Flags to pass to `npm pack`.
|
|
|
|
, npmPackFlags ? [ ]
|
2023-07-15 17:15:38 +00:00
|
|
|
# Flags to pass to `npm prune`.
|
|
|
|
, npmPruneFlags ? npmInstallFlags
|
|
|
|
# Value for npm `--workspace` flag and directory in which the files to be installed are found.
|
|
|
|
, npmWorkspace ? null
|
2022-11-21 17:40:18 +00:00
|
|
|
, ...
|
|
|
|
} @ args:
|
|
|
|
|
|
|
|
let
|
|
|
|
npmDeps = fetchNpmDeps {
|
2023-04-29 16:46:19 +00:00
|
|
|
inherit forceGitDeps src srcs sourceRoot prePatch patches postPatch;
|
2022-11-21 17:40:18 +00:00
|
|
|
name = "${name}-npm-deps";
|
|
|
|
hash = npmDepsHash;
|
|
|
|
};
|
|
|
|
|
|
|
|
inherit (npmHooks.override { inherit nodejs; }) npmConfigHook npmBuildHook npmInstallHook;
|
|
|
|
in
|
|
|
|
stdenv.mkDerivation (args // {
|
|
|
|
inherit npmDeps npmBuildScript;
|
|
|
|
|
|
|
|
nativeBuildInputs = nativeBuildInputs ++ [ nodejs npmConfigHook npmBuildHook npmInstallHook ];
|
|
|
|
buildInputs = buildInputs ++ [ nodejs ];
|
|
|
|
|
|
|
|
strictDeps = true;
|
|
|
|
|
|
|
|
# Stripping takes way too long with the amount of files required by a typical Node.js project.
|
|
|
|
dontStrip = args.dontStrip or true;
|
|
|
|
|
|
|
|
meta = (args.meta or { }) // { platforms = args.meta.platforms or nodejs.meta.platforms; };
|
|
|
|
})
|