at 25.11-pre 1.6 kB view raw
1{ 2 writeScriptBin, 3 stdenv, 4 lib, 5 elm, 6}: 7let 8 patchBinwrap = 9 let 10 # Patching binwrap by NoOp script 11 binwrap = writeScriptBin "binwrap" '' 12 #! ${stdenv.shell} 13 echo "binwrap called: Returning 0" 14 return 0 15 ''; 16 binwrap-install = writeScriptBin "binwrap-install" '' 17 #! ${stdenv.shell} 18 echo "binwrap-install called: Doing nothing" 19 ''; 20 in 21 targets: pkg: 22 pkg.override (old: { 23 nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ 24 binwrap 25 binwrap-install 26 ]; 27 28 # Manually install targets 29 # by symlinking binaries into `node_modules` 30 postInstall = 31 let 32 binFile = module: lib.strings.removeSuffix ("-" + module.version) module.name; 33 in 34 (old.postInstall or "") 35 + '' 36 ${lib.concatStrings ( 37 map (module: '' 38 echo "linking ${binFile module}" 39 ln -sf ${module}/bin/${binFile module} \ 40 node_modules/${binFile module}/bin/${binFile module} 41 '') targets 42 )} 43 ''; 44 }); 45 46 patchNpmElm = 47 pkg: 48 pkg.override (old: { 49 preRebuild = 50 (old.preRebuild or "") 51 + '' 52 rm node_modules/elm/install.js 53 echo "console.log('Nixpkgs\' version of Elm will be used');" > node_modules/elm/install.js 54 ''; 55 postInstall = 56 (old.postInstall or "") 57 + '' 58 ln -sf ${elm}/bin/elm node_modules/elm/bin/elm 59 ''; 60 }); 61in 62{ 63 inherit patchBinwrap patchNpmElm; 64}