diff --git a/default.nix b/default.nix index d01013d..3b87632 100644 --- a/default.nix +++ b/default.nix @@ -6,7 +6,7 @@ let nodeEnv = import ./nix/node-env.nix { - inherit (pkgs) stdenv lib python2 runCommand writeTextFile writeShellScript; + inherit (pkgs) stdenv lib python2 runCommand writeTextFile writeShellScript jq; inherit pkgs nodejs; libtool = if pkgs.stdenv.isDarwin then pkgs.darwin.cctools else null; }; diff --git a/lib/expressions/CompositionExpression.js b/lib/expressions/CompositionExpression.js index 474ff0d..6f133ca 100644 --- a/lib/expressions/CompositionExpression.js +++ b/lib/expressions/CompositionExpression.js @@ -129,6 +129,7 @@ CompositionExpression.prototype.toNixAST = function() { runCommand: new nijs.NixInherit("pkgs"), writeTextFile: new nijs.NixInherit("pkgs"), writeShellScript: new nijs.NixInherit("pkgs"), + jq: new nijs.NixInherit("pkgs"), pkgs: new nijs.NixInherit(), nodejs: new nijs.NixInherit() } diff --git a/nix/node-env.nix b/nix/node-env.nix index 219050b..e44a536 100644 --- a/nix/node-env.nix +++ b/nix/node-env.nix @@ -1,6 +1,6 @@ # This file originates from node2nix -{lib, stdenv, nodejs, python2, pkgs, libtool, runCommand, writeTextFile, writeShellScript}: +{lib, stdenv, nodejs, python2, pkgs, libtool, runCommand, writeTextFile, writeShellScript, jq}: let # Workaround to cope with utillinux in Nixpkgs 20.09 and util-linux in Nixpkgs master @@ -84,6 +84,16 @@ let # Change to the package directory to install dependencies cd "$DIR/$packageName" + + # Patch shebangs in any binary files + if [ -f package.json ]; then + set +e + for file in $(cat package.json | ${jq}/bin/jq '((.bin // {}) | if type=="string" then [.] else (. | values) end) | .[]' -r); do + chmod u+x "$file" + patchShebangs "$file" + done + set -e + fi } ''; @@ -483,6 +493,7 @@ let , dontNpmInstall ? false , bypassCache ? false , reconstructLock ? false + , preRebuild ? "" , dontStrip ? true , unpackPhase ? "true" , buildPhase ? "true" @@ -500,7 +511,7 @@ let ++ buildInputs; inherit dontStrip; # Stripping may fail a build for some package deployments - inherit dontNpmInstall unpackPhase buildPhase; + inherit dontNpmInstall preRebuild unpackPhase buildPhase; includeScript = includeDependencies { inherit dependencies; }; pinpointDependenciesScript = pinpointDependenciesOfPackage args;