Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 fetchYarnDeps,
6 makeWrapper,
7 nodejs,
8 fixup-yarn-lock,
9 yarn,
10}:
11
12stdenv.mkDerivation rec {
13 pname = "pkg";
14 version = "5.8.1";
15
16 src = fetchFromGitHub {
17 owner = "vercel";
18 repo = "pkg";
19 rev = version;
20 hash = "sha256-h3rHR3JE9hVcd3oiE7VL2daYXGTQo7NcOHGC6pmE/xs=";
21 };
22
23 offlineCache = fetchYarnDeps {
24 yarnLock = "${src}/yarn.lock";
25 hash = "sha256-KesP3X7LwZ7KSIxcCPXdn/sWcX9TJlwT9z/SdotS2ZQ=";
26 };
27
28 nativeBuildInputs = [
29 makeWrapper
30 nodejs
31 fixup-yarn-lock
32 yarn
33 ];
34
35 configurePhase = ''
36 runHook preConfigure
37
38 export HOME=$(mktemp -d)
39 yarn config --offline set yarn-offline-mirror "$offlineCache"
40 fixup-yarn-lock yarn.lock
41 yarn --offline --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive install
42 patchShebangs node_modules
43
44 runHook postConfigure
45 '';
46
47 buildPhase = ''
48 runHook preBuild
49
50 yarn --offline prepare
51
52 runHook postBuild
53 '';
54
55 installPhase = ''
56 runHook preInstall
57
58 yarn --offline --production install
59
60 mkdir -p "$out/lib/node_modules/pkg"
61 cp -r . "$out/lib/node_modules/pkg"
62
63 makeWrapper "${nodejs}/bin/node" "$out/bin/pkg" \
64 --add-flags "$out/lib/node_modules/pkg/lib-es5/bin.js"
65
66 runHook postInstall
67 '';
68
69 meta = {
70 description = "Package your Node.js project into an executable";
71 homepage = "https://github.com/vercel/pkg";
72 license = lib.licenses.mit;
73 mainProgram = "pkg";
74 maintainers = with lib.maintainers; [ cmcdragonkai ];
75 platforms = lib.platforms.all;
76 };
77}