about summary refs log tree commit diff
path: root/nix/buildBazelPackageNG/bazelRulesNodeJS5Hook/default.nix
blob: 21703dea0a82abf9afbd4cccf79e3f998c2115e9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
{ stdenvNoCC
, lib
, makeSetupHook
, fetchFromGitHub
, coreutils
, gnugrep
, nodejs
, yarn
, git
, cacert
}:
let
  rulesNodeJS = stdenvNoCC.mkDerivation rec {
    pname = "bazelbuild-rules_nodejs";
    version = "5.8.5";

    src = fetchFromGitHub {
      owner = "bazelbuild";
      repo = "rules_nodejs";
      rev = version;
      hash = "sha256-6UbYRrOnS93+pK4VI016gQZv2jLCzkJn6wJ4vZNCNjY=";
    };

    dontBuild = true;

    postPatch = ''
      shopt -s globstar
      for i in **/*.bzl **/*.sh **/*.cjs; do
        substituteInPlace "$i" \
          --replace-quiet '#!/usr/bin/env bash' '#!${stdenvNoCC.shell}' \
          --replace-quiet '#!/bin/bash' '#!${stdenvNoCC.shell}'
      done
      sed -i '/^#!/a export PATH=${lib.makeBinPath [ coreutils gnugrep ]}:$PATH' internal/node/launcher.sh
    '';

    installPhase = ''
      cp -R . $out
    '';
  };
in
makeSetupHook
{
  name = "bazelbuild-rules_nodejs-5-hook";
  propagatedBuildInputs = [
    nodejs
    yarn
    git
    cacert
  ];
  substitutions = {
    inherit nodejs yarn cacert rulesNodeJS;
    local_node = ./local_node;
    local_yarn = ./local_yarn;
  };
} ./setup-hook.sh