11{ pkgs
2+ , lib
23, nix-gitignore
34, our-ghc
45, makeWrapper
910, gmp
1011, name
1112, main
13+ , importNpmLock
1214} :
1315let
14- nodeEnv = import ./node/node-env.nix {
15- inherit ( pkgs ) stdenv lib python2 runCommand writeTextFile writeShellScript nodejs ;
16- inherit pkgs ;
17- libtool = if pkgs . stdenv . isDarwin then pkgs . darwin . cctools else null ;
18- } ;
16+ nodeModules = importNpmLock . buildNodeModules {
17+ npmRoot = ../.. ;
18+ inherit ( pkgs ) nodejs ;
1919
20- # To cut down on the image size we maim all references to Python and bash here.
21- nodeDependencies = ( import ./node/node-dependencies.nix {
22- inherit ( pkgs ) fetchurl nix-gitignore stdenv lib fetchgit ;
23- inherit nodeEnv ;
24- } ) . nodeDependencies . overrideDerivation ( old : {
25- installPhase = ''
26- ${ old . installPhase }
27- find $out -print0 | xargs -0 ${ pkgs . removeReferencesTo } /bin/remove-references-to -t ${ pkgs . python3 }
28- find $out -print0 | xargs -0 ${ pkgs . removeReferencesTo } /bin/remove-references-to -t ${ pkgs . bash }
29- '' ;
30- } ) ;
20+ # To cut down on the image size we maim some references here.
21+ derivationArgs = let
22+ forbiddenRefs = [
23+ pkgs . python3
24+ pkgs . bashNonInteractive
25+ ] ;
26+ in {
27+ nativeBuildInputs = [ removeReferencesTo ] ;
28+ postInstall = ''
29+ find "$out" -exec remove-references-to ${ lib . concatMapStringsSep " " ( x : "-t ${ lib . escapeShellArg x } " ) forbiddenRefs } '{}' +
30+ '' ;
31+ disallowedReferences = forbiddenRefs ;
32+ } ;
33+ } ;
3134in
3235stdenv . mkDerivation {
3336 inherit name ;
@@ -36,7 +39,8 @@ stdenv.mkDerivation {
3639 propagatedBuildInputs = [ lua5_3 gmp ] ;
3740
3841 buildPhase = ''
39- ghc -o ${ main } app/${ main } -threaded -with-rtsopts "-A128M -N -I0" -rtsopts -iapp -O2 -split-sections -DNODE_LIB_PATH="\"${ nodeDependencies } /lib/node_modules\"" -DNODE_BIN_PATH="\"${ nodeDependencies } /bin\""
42+ ghc -o ${ main } app/${ main } -threaded -with-rtsopts "-A128M -N -I0" -rtsopts -iapp -O2 -split-sections \
43+ -DNODE_BIN_PATH="\"${ nodeModules } /node_modules/.bin\"" # see Utils.hs
4044 '' ;
4145
4246 installPhase = ''
@@ -52,8 +56,7 @@ stdenv.mkDerivation {
5256 remove-references-to -t ${ labHaskellPackages . js-dgtable } ${ main }
5357 cp ${ main } $out/bin/${ name }
5458 wrapProgram $out/bin/${ name } \
55- --prefix PATH : ${ nodeDependencies } /bin \
56- --prefix NODE_PATH : ${ nodeDependencies } /lib/node_modules
59+ --prefix NODE_PATH : ${ nodeModules } /node_modules
5760 '' ;
5861
5962 disallowedReferences = with labHaskellPackages ; [
0 commit comments