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