Commit bd374243 authored by sternenseemann's avatar sternenseemann
Browse files

npmHooks: use adjacent packages, not buildPackages

Hooks are essentially implemented as special shell packages that run on
their respective host platform. When they are used, they appear as
nativeBuildInputs (as they need to be executed as part of the build of a
package using them) so are taken from buildPackages relative to the
derivation using them.

Since the override in buildNpmPackage nullifies splicing, we take
npmHooks from buildPackages manually.

Fixes pkgsCross.ghcjs.buildPackages.emscripten and thus
pkgsCross.ghcjs.haskellPackages.ghc.
parent 9f48070e
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
{ lib, stdenv, fetchNpmDeps, npmHooks, nodejs }:
{ lib, stdenv, fetchNpmDeps, buildPackages, nodejs }:

{ name ? "${args.pname}-${args.version}"
, src ? null
@@ -44,7 +44,12 @@ let
    hash = npmDepsHash;
  };

  inherit (npmHooks.override { inherit nodejs; }) npmConfigHook npmBuildHook npmInstallHook;
  # .override {} negates splicing, so we need to use buildPackages explicitly
  npmHooks = buildPackages.npmHooks.override {
    inherit nodejs;
  };

  inherit (npmHooks) npmConfigHook npmBuildHook npmInstallHook;
in
stdenv.mkDerivation (args // {
  inherit npmDeps npmBuildScript;
+16 −7
Original line number Diff line number Diff line
{ lib, makeSetupHook, nodejs, srcOnly, buildPackages, makeWrapper }:
{ lib
, srcOnly
, makeSetupHook
, makeWrapper
, nodejs
, jq
, prefetch-npm-deps
, diffutils
, installShellFiles
}:

{
  npmConfigHook = makeSetupHook
@@ -6,13 +15,13 @@
      name = "npm-config-hook";
      substitutions = {
        nodeSrc = srcOnly nodejs;
        nodeGyp = "${buildPackages.nodejs}/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js";
        nodeGyp = "${nodejs}/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js";

        # Specify `diff`, `jq`, and `prefetch-npm-deps` by abspath to ensure that the user's build
        # inputs do not cause us to find the wrong binaries.
        diff = "${buildPackages.diffutils}/bin/diff";
        jq = "${buildPackages.jq}/bin/jq";
        prefetchNpmDeps = "${buildPackages.prefetch-npm-deps}/bin/prefetch-npm-deps";
        diff = "${diffutils}/bin/diff";
        jq = "${jq}/bin/jq";
        prefetchNpmDeps = "${prefetch-npm-deps}/bin/prefetch-npm-deps";

        nodeVersion = nodejs.version;
        nodeVersionMajor = lib.versions.major nodejs.version;
@@ -27,13 +36,13 @@
  npmInstallHook = makeSetupHook
    {
      name = "npm-install-hook";
      propagatedBuildInputs = with buildPackages; [
      propagatedBuildInputs = [
        installShellFiles
        makeWrapper
      ];
      substitutions = {
        hostNode = "${nodejs}/bin/node";
        jq = "${buildPackages.jq}/bin/jq";
        jq = "${jq}/bin/jq";
      };
    } ./npm-install-hook.sh;
}