@@ -98,7 +98,6 @@ pkgs.lib.makeExtensible
98
98
${ pkgs . lib . escapeShellArg dataFolder } \
99
99
${ pkgs . lib . escapeShellArg dataLinkFarm }
100
100
101
-
102
101
[[ -e ${ pkgs . lib . escapeShellArg dataFolder } ]] && \
103
102
printf "flake-lang.nix: %s: removing existing \`%s\`\n" \
104
103
${ pkgs . lib . escapeShellArg name } \
@@ -126,6 +125,7 @@ pkgs.lib.makeExtensible
126
125
cd $out
127
126
128
127
${ builtins . concatStringsSep "\n " ( builtins . map ( dep : ''ln -sf ${ pkgs . lib . escapeShellArg dep } /tarballs/* .'' ) npmExtraDependenciesTransitiveClosure ) }
128
+
129
129
'' ;
130
130
131
131
# Shell script to create the dependencies copied in `npmExtraDependenciesTransitiveClosure`.
@@ -272,6 +272,34 @@ pkgs.lib.makeExtensible
272
272
# rm package-lock.json
273
273
# '';
274
274
# ```
275
+ # NOTE(jaredponn): Yet another troubling note.. inspection of the
276
+ # code generated by `node2nix` makes it call `npm` install (unless
277
+ # otherwise specified) just after their `rebuildPhase`.
278
+ # Putting this here seems to "tell `npm` the complete picture" of the
279
+ # packages it can install, so it won't duplicate the local
280
+ # dependencies in the `node_modules` provided by nix multiple times.
281
+ # For example, if we have
282
+ # - A depends on B
283
+ # - B depends on C
284
+ # Then, without this, `npm` would create a dependency graph something
285
+ # like:
286
+ # ```
287
+ # A-B-C
288
+ # `C
289
+ # ```
290
+ # instead of the more desirable
291
+ # ```
292
+ # A-B
293
+ # `C
294
+ # ```
295
+ # Unfortunately, there is no trace of this in the documentation
296
+ # anywhere, and we only have some experimental evidence for this.
297
+ # Alternatively, we could just set the `dontNpmInstall` flag in
298
+ # node2nix, but I'm not sure of the consequences of that...
299
+ postRebuild =
300
+ ''
301
+ npm --offline --no-bin-links --ignore-scripts --package-lock-only install
302
+ '' ;
275
303
} )
276
304
;
277
305
0 commit comments