1{ pkgs, nodejs, stdenv, fetchFromGitHub }:
2
3let
4 since = (version: pkgs.lib.versionAtLeast nodejs.version version);
5 before = (version: pkgs.lib.versionOlder nodejs.version version);
6 super = import ./composition.nix {
7 inherit pkgs nodejs;
8 inherit (stdenv.hostPlatform) system;
9 };
10 self = super // {
11 "@angular/cli" = super."@angular/cli".override {
12 prePatch = ''
13 export NG_CLI_ANALYTICS=false
14 '';
15 };
16
17 aws-azure-login = super.aws-azure-login.override {
18 meta.platforms = pkgs.lib.platforms.linux;
19 nativeBuildInputs = [ pkgs.makeWrapper ];
20 prePatch = ''
21 export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1
22 '';
23 postInstall = ''
24 wrapProgram $out/bin/aws-azure-login \
25 --set PUPPETEER_EXECUTABLE_PATH ${pkgs.chromium}/bin/chromium
26 '';
27 };
28
29 bower2nix = super.bower2nix.override {
30 buildInputs = [ pkgs.makeWrapper ];
31 postInstall = ''
32 for prog in bower2nix fetch-bower; do
33 wrapProgram "$out/bin/$prog" --prefix PATH : ${pkgs.lib.makeBinPath [ pkgs.git pkgs.nix ]}
34 done
35 '';
36 };
37
38 coc-imselect = super.coc-imselect.override {
39 meta.broken = since "10";
40 };
41
42 "fast-cli-1.x" = super."fast-cli-1.x".override {
43 meta.broken = since "10";
44 };
45
46 jshint = super.jshint.override {
47 buildInputs = [ pkgs.phantomjs2 ];
48 };
49
50 dat = super.dat.override {
51 buildInputs = [ self.node-gyp-build pkgs.libtool pkgs.autoconf pkgs.automake ];
52 meta.broken = since "12";
53 };
54
55 # NOTE: this is a stub package to fetch npm dependencies for
56 # ../../applications/video/epgstation
57 epgstation = super."epgstation-../../applications/video/epgstation".override (drv: {
58 meta = drv.meta // {
59 broken = true; # not really broken, see the comment above
60 };
61 });
62
63 bitwarden-cli = super."@bitwarden/cli".override (drv: {
64 name = "bitwarden-cli-${drv.version}";
65 meta.mainProgram = "bw";
66 });
67
68 fast-cli = super."fast-cli-1.x".override {
69 preRebuild = ''
70 # Simply ignore the phantomjs --version check. It seems to need a display but it is safe to ignore
71 sed -i -e "s|console.error('Error verifying phantomjs, continuing', err)|console.error('Error verifying phantomjs, continuing', err); return true;|" node_modules/phantomjs-prebuilt/lib/util.js
72 '';
73 buildInputs = [ pkgs.phantomjs2 ];
74 };
75
76 flood = super.flood.override {
77 buildInputs = [ self.node-pre-gyp ];
78 };
79
80 expo-cli = super."expo-cli".override (attrs: {
81 # The traveling-fastlane-darwin optional dependency aborts build on Linux.
82 dependencies = builtins.filter (d: d.packageName != "@expo/traveling-fastlane-${if stdenv.isLinux then "darwin" else "linux"}") attrs.dependencies;
83 });
84
85 "@electron-forge/cli" = super."@electron-forge/cli".override {
86 buildInputs = [ self.node-pre-gyp self.rimraf ];
87 };
88
89 git-ssb = super.git-ssb.override {
90 buildInputs = [ self.node-gyp-build ];
91 meta.broken = since "10";
92 };
93
94 hsd = super.hsd.override {
95 buildInputs = [ self.node-gyp-build pkgs.unbound ];
96 };
97
98 ijavascript = super.ijavascript.override (oldAttrs: {
99 preRebuild = ''
100 export NPM_CONFIG_ZMQ_EXTERNAL=true
101 '';
102 buildInputs = oldAttrs.buildInputs ++ [ self.node-gyp-build pkgs.zeromq ];
103 });
104
105 insect = super.insect.override (drv: {
106 nativeBuildInputs = drv.nativeBuildInputs or [] ++ [ pkgs.psc-package self.pulp ];
107 });
108
109 makam = super.makam.override {
110 buildInputs = [ pkgs.nodejs pkgs.makeWrapper ];
111 postFixup = ''
112 wrapProgram "$out/bin/makam" --prefix PATH : ${pkgs.lib.makeBinPath [ pkgs.nodejs ]}
113 ${
114 if stdenv.isLinux
115 then "patchelf --set-interpreter ${stdenv.glibc}/lib/ld-linux-x86-64.so.2 \"$out/lib/node_modules/makam/makam-bin-linux64\""
116 else ""
117 }
118 '';
119 };
120
121 mirakurun = super.mirakurun.override rec {
122 nativeBuildInputs = with pkgs; [ makeWrapper ];
123 postInstall = let
124 runtimeDeps = [ nodejs ] ++ (with pkgs; [ bash which v4l-utils ]);
125 in
126 ''
127 substituteInPlace $out/lib/node_modules/mirakurun/processes.json \
128 --replace "/usr/local" ""
129
130 # XXX: Files copied from the Nix store are non-writable, so they need
131 # to be given explicit write permissions
132 substituteInPlace $out/lib/node_modules/mirakurun/lib/Mirakurun/config.js \
133 --replace 'fs.copyFileSync("config/server.yml", path);' \
134 'fs.copyFileSync("config/server.yml", path); fs.chmodSync(path, 0o644);' \
135 --replace 'fs.copyFileSync("config/tuners.yml", path);' \
136 'fs.copyFileSync("config/tuners.yml", path); fs.chmodSync(path, 0o644);' \
137 --replace 'fs.copyFileSync("config/channels.yml", path);' \
138 'fs.copyFileSync("config/channels.yml", path); fs.chmodSync(path, 0o644);'
139
140 # XXX: The original mirakurun command uses PM2 to manage the Mirakurun
141 # server. However, we invoke the server directly and let systemd
142 # manage it to avoid complication. This is okay since no features
143 # unique to PM2 is currently being used.
144 makeWrapper ${nodejs}/bin/npm $out/bin/mirakurun \
145 --add-flags "start" \
146 --run "cd $out/lib/node_modules/mirakurun" \
147 --prefix PATH : ${pkgs.lib.makeBinPath runtimeDeps}
148 '';
149 };
150
151 node-inspector = super.node-inspector.override {
152 buildInputs = [ self.node-pre-gyp ];
153 meta.broken = since "10";
154 };
155
156 node2nix = super.node2nix.override {
157 buildInputs = [ pkgs.makeWrapper ];
158 postInstall = ''
159 wrapProgram "$out/bin/node2nix" --prefix PATH : ${pkgs.lib.makeBinPath [ pkgs.nix ]}
160 '';
161 };
162
163 node-red = super.node-red.override {
164 buildInputs = [ self.node-pre-gyp ];
165 };
166
167 mermaid-cli = super."@mermaid-js/mermaid-cli".override (
168 if stdenv.isDarwin
169 then {}
170 else {
171 nativeBuildInputs = [ pkgs.makeWrapper ];
172 prePatch = ''
173 export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1
174 '';
175 postInstall = ''
176 wrapProgram $out/bin/mmdc \
177 --set PUPPETEER_EXECUTABLE_PATH ${pkgs.chromium.outPath}/bin/chromium
178 '';
179 });
180
181 pnpm = super.pnpm.override {
182 nativeBuildInputs = [ pkgs.makeWrapper ];
183
184 preRebuild = ''
185 sed 's/"link:/"file:/g' --in-place package.json
186 '';
187
188 postInstall = let
189 pnpmLibPath = pkgs.lib.makeBinPath [
190 nodejs.passthru.python
191 nodejs
192 ];
193 in ''
194 for prog in $out/bin/*; do
195 wrapProgram "$prog" --prefix PATH : ${pnpmLibPath}
196 done
197 '';
198 };
199
200 pulp = super.pulp.override {
201 # tries to install purescript
202 npmFlags = "--ignore-scripts";
203
204 nativeBuildInputs = [ pkgs.makeWrapper ];
205 postInstall = ''
206 wrapProgram "$out/bin/pulp" --suffix PATH : ${pkgs.lib.makeBinPath [
207 pkgs.purescript
208 ]}
209 '';
210 };
211
212 netlify-cli =
213 let
214 esbuild = pkgs.esbuild.overrideAttrs (old: rec {
215 version = "0.11.14";
216
217 src = fetchFromGitHub {
218 owner = "evanw";
219 repo = "esbuild";
220 rev = "v${version}";
221 sha256 = "sha256-N7WNam0zF1t++nLVhuxXSDGV/JaFtlFhufp+etinvmM=";
222 };
223
224 });
225 in
226 super.netlify-cli.override {
227 preRebuild = ''
228 export ESBUILD_BINARY_PATH="${esbuild}/bin/esbuild"
229 '';
230 };
231
232 ssb-server = super.ssb-server.override {
233 buildInputs = [ pkgs.automake pkgs.autoconf self.node-gyp-build ];
234 meta.broken = since "10";
235 };
236
237 stf = super.stf.override {
238 meta.broken = since "10";
239 };
240
241 tedicross = super."tedicross-git+https://github.com/TediCross/TediCross.git#v0.8.7".override {
242 nativeBuildInputs = [ pkgs.makeWrapper ];
243 postInstall = ''
244 makeWrapper '${nodejs}/bin/node' "$out/bin/tedicross" \
245 --add-flags "$out/lib/node_modules/tedicross/main.js"
246 '';
247 };
248
249 tsun = super.tsun.overrideAttrs (oldAttrs: {
250 buildInputs = oldAttrs.buildInputs ++ [ pkgs.makeWrapper ];
251 postInstall = ''
252 wrapProgram "$out/bin/tsun" \
253 --prefix NODE_PATH : ${self.typescript}/lib/node_modules
254 '';
255 });
256
257 typescript-language-server = super.typescript-language-server.override {
258 nativeBuildInputs = [ pkgs.makeWrapper ];
259 postInstall = ''
260 wrapProgram "$out/bin/typescript-language-server" \
261 --prefix PATH : ${pkgs.lib.makeBinPath [ self.typescript ]}
262 '';
263 };
264
265 teck-programmer = super.teck-programmer.override {
266 buildInputs = [ pkgs.libusb ];
267 };
268
269 vega-cli = super.vega-cli.override {
270 nativeBuildInputs = [ pkgs.pkg-config ];
271 buildInputs = with pkgs; [
272 super.node-pre-gyp
273 pixman
274 cairo
275 pango
276 libjpeg
277 ];
278 };
279
280 vega-lite = super.vega-lite.override {
281 # npx tries to install vega from scratch at vegalite runtime if it
282 # can't find it. We thus replace it with a direct call to the nix
283 # derivation. This might not be necessary anymore in future vl
284 # versions: https://github.com/vega/vega-lite/issues/6863.
285 postInstall = ''
286 substituteInPlace $out/lib/node_modules/vega-lite/bin/vl2pdf \
287 --replace "npx -p vega vg2pdf" "${self.vega-cli}/bin/vg2pdf"
288 substituteInPlace $out/lib/node_modules/vega-lite/bin/vl2svg \
289 --replace "npx -p vega vg2svg" "${self.vega-cli}/bin/vg2svg"
290 substituteInPlace $out/lib/node_modules/vega-lite/bin/vl2png \
291 --replace "npx -p vega vg2png" "${self.vega-cli}/bin/vg2png"
292 '';
293 };
294
295 webtorrent-cli = super.webtorrent-cli.override {
296 buildInputs = [ self.node-gyp-build ];
297 };
298
299 joplin = super.joplin.override {
300 nativeBuildInputs = [ pkgs.pkg-config ];
301 buildInputs = with pkgs; [
302 # required by sharp
303 # https://sharp.pixelplumbing.com/install
304 vips
305
306 libsecret
307 self.node-gyp-build
308 self.node-pre-gyp
309 ] ++ lib.optionals stdenv.isDarwin [
310 darwin.apple_sdk.frameworks.AppKit
311 darwin.apple_sdk.frameworks.Security
312 ];
313 };
314
315 thelounge = super.thelounge.override {
316 buildInputs = [ self.node-pre-gyp ];
317 postInstall = ''
318 echo /var/lib/thelounge > $out/lib/node_modules/thelounge/.thelounge_home
319 '';
320 };
321
322 yaml-language-server = super.yaml-language-server.override {
323 nativeBuildInputs = [ pkgs.makeWrapper ];
324 postInstall = ''
325 wrapProgram "$out/bin/yaml-language-server" \
326 --prefix NODE_PATH : ${self.prettier}/lib/node_modules
327 '';
328 };
329 };
330in self