nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 buildNpmPackage,
4 fetchFromGitHub,
5 pkg-config,
6 pixman,
7 cairo,
8 pango,
9 jq,
10}:
11
12buildNpmPackage (finalAttrs: {
13 pname = "vega-cli";
14 version = "6.2.0";
15
16 src = fetchFromGitHub {
17 owner = "vega";
18 repo = "vega";
19 tag = "v${finalAttrs.version}";
20 hash = "sha256-YO3YzTRNJKDOgCxMXnw2P2d1ZN79Db3//L9iLjDGiyM=";
21 };
22
23 postPatch = ''
24 # We never need this, so just skip it to save some time while building.
25 patchShebangs scripts/postinstall.sh
26 substituteInPlace scripts/postinstall.sh \
27 --replace-fail "npm run data" "true"
28
29 # Patch lerna.json to not use nx
30 mv lerna.json lerna.old.json
31 jq '. + {useNx: false}' < lerna.old.json > lerna.json
32 '';
33
34 npmDepsHash = "sha256-mBe1fHnhor7ZR8CuRNs1zD7JzaZXZI5VM7mdAieVKqE=";
35
36 npmWorkspace = "vega-cli";
37
38 buildInputs = [
39 pixman
40 cairo
41 pango
42 ];
43
44 nativeBuildInputs = [
45 pkg-config
46 jq
47 ];
48
49 buildPhase = ''
50 runHook preBuild
51
52 npm run build --scope vega-cli --include-dependencies --stream
53
54 runHook postBuild
55 '';
56
57 installPhase = ''
58 runHook preInstall
59
60 # prune non-prod deps
61 npm prune --omit=dev --no-save --workspace vega-cli
62
63 mkdir -p $out/lib/node_modules/vega-cli
64 rm -rf packages/**/{test,*.md,.npmignore}
65 cp -r ./packages ./node_modules $out/lib/node_modules/vega-cli
66 ln -s $out/lib/node_modules/vega-cli/packages/vega-cli/bin $out/bin
67
68 runHook postInstall
69 '';
70
71 meta = {
72 description = "Command line tools for the Vega visualization grammar";
73 homepage = "https://vega.github.io/vega/";
74 license = lib.licenses.bsd3;
75 maintainers = with lib.maintainers; [ pyrox0 ];
76 };
77})