summary refs log tree commit diff
path: root/pkgs/top-level/node-packages.nix
blob: a0cbd5c4a8b1bc274124f0417e78c5c4d95ee82f (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
56
57
58
59
60
61
62
63
64
65
66
{
  stdenv, pkgs, nodejs

  # Self-reference
, self

  # Needed natives for installation
, neededNatives ? [pkgs.python] ++ stdenv.lib.optionals stdenv.isLinux [ pkgs.utillinux ]

  # Attribute set of generated packages
, generated ? pkgs.callPackage ./node-packages-generated.nix { inherit self; }

  # Attribute set of overrides
, overrides ? {}
, ...
} @ args:

with stdenv.lib;

rec {
  overrides = {
    phantomjs.buildInputs = [ pkgs.phantomjs ];
    "node-expat".buildInputs = [ pkgs.expat ];
    "node-stringprep".buildInputs = [ pkgs.icu pkgs.which ];
    "node-protobuf".buildInputs = [ pkgs.protobuf ];
    "rbytes".buildInputs = [ pkgs.openssl ];

    bipio.patchPhase = ''
      ${self.json}/bin/json -I -f package.json -e 'this.scripts.install=""'
    '';
    bip-pod.patchPhase = ''
      substituteInPlace index.js --replace \
        "__dirname + (literal ? '/' : '/../bip-pod-') + podName" \
        "(literal ? __dirname + '/' : \"bip-pod-\") + podName"
    '';
  } // args.overrides or {};

  # Apply overrides and back compatiblity transformations
  buildNodePackage = {...} @ args:
  let
    pkg = makeOverridable (
      pkgs.callPackage ../development/web/nodejs/build-node-package.nix {
        inherit nodejs neededNatives;
      }
    ) (args // (optionalAttrs (isList args.src) {
      # Backwards compatibility
      src = head args.src;
    }) // (optionalAttrs (attrByPath ["passthru" "names"] null args != null) {
       pkgName = head args.passthru.names;
    }));

    override = overrides.${args.name} or overrides.${pkg.pkgName} or {};

  in pkg.override override;

  # Backwards compatibility
  patchSource = fn: srcAttrs: fn srcAttrs;
  patchLatest = patchSource pkgs.fetchurl;

  /* Put manual packages below here (ideally eventually managed by npm2nix */
} // (
  if isAttrs generated then generated

  # Backwards compatiblity
  else pkgs.callPackage generated { inherit self; }
)