Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib, stdenv, fetchNpmDeps, npmHooks, nodejs }:
2
3{ name ? "${args.pname}-${args.version}"
4, src ? null
5, srcs ? null
6, sourceRoot ? null
7, prePatch ? ""
8, patches ? [ ]
9, postPatch ? ""
10, nativeBuildInputs ? [ ]
11, buildInputs ? [ ]
12 # The output hash of the dependencies for this project.
13 # Can be calculated in advance with prefetch-npm-deps.
14, npmDepsHash ? ""
15 # Whether to force the usage of Git dependencies that have install scripts, but not a lockfile.
16 # Use with care.
17, forceGitDeps ? false
18 # Whether to make the cache writable prior to installing dependencies.
19 # Don't set this unless npm tries to write to the cache directory, as it can slow down the build.
20, makeCacheWritable ? false
21 # The script to run to build the project.
22, npmBuildScript ? "build"
23 # Flags to pass to all npm commands.
24, npmFlags ? [ ]
25 # Flags to pass to `npm ci` and `npm prune`.
26, npmInstallFlags ? [ ]
27 # Flags to pass to `npm rebuild`.
28, npmRebuildFlags ? [ ]
29 # Flags to pass to `npm run ${npmBuildScript}`.
30, npmBuildFlags ? [ ]
31 # Flags to pass to `npm pack`.
32, npmPackFlags ? [ ]
33, ...
34} @ args:
35
36let
37 npmDeps = fetchNpmDeps {
38 inherit forceGitDeps src srcs sourceRoot prePatch patches postPatch;
39 name = "${name}-npm-deps";
40 hash = npmDepsHash;
41 };
42
43 inherit (npmHooks.override { inherit nodejs; }) npmConfigHook npmBuildHook npmInstallHook;
44in
45stdenv.mkDerivation (args // {
46 inherit npmDeps npmBuildScript;
47
48 nativeBuildInputs = nativeBuildInputs ++ [ nodejs npmConfigHook npmBuildHook npmInstallHook ];
49 buildInputs = buildInputs ++ [ nodejs ];
50
51 strictDeps = true;
52
53 # Stripping takes way too long with the amount of files required by a typical Node.js project.
54 dontStrip = args.dontStrip or true;
55
56 passthru = { inherit npmDeps; } // (args.passthru or { });
57
58 meta = (args.meta or { }) // { platforms = args.meta.platforms or nodejs.meta.platforms; };
59})