summary refs log tree commit diff
path: root/pkgs/development/beam-modules/lib.nix
blob: 9d7a4bbd34ed4fac80635412290eafd7bf8106a0 (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
{ pkgs, stdenv }:

rec {

  /* Similar to callPackageWith/callPackage, but without makeOverridable
  */
  callPackageWith = autoArgs: fn: args:
    let
      f = if builtins.isFunction fn then fn else import fn;
      auto = builtins.intersectAttrs (builtins.functionArgs f) autoArgs;
    in f (auto // args);

  callPackage = callPackageWith pkgs;

  /* Erlang/OTP-specific version retrieval, returns 19 for OTP R19 */
  getVersion = x:
   let
     parse = drv: (builtins.parseDrvName drv).version;
   in builtins.replaceStrings ["B" "-"] ["." "."] (
      if builtins.isString x
      then parse x
      else x.version or (parse x.name));

  /* Uses generic-builder to evaluate provided drv containing OTP-version
  specific data.

  drv: package containing version-specific args;
  builder: generic builder for all Erlang versions;
  args: arguments merged into version-specific args, used mostly to customize
        dependencies;

  Arguments passed to the generic-builder are overridable, used to
  enable/disable high-level OTP features, like ODBC or WX support;

  Please note that "mkDerivation" defined here is the one called from R16.nix
  and similar files.
  */
  callErlang = drv: args:
    let
      builder = callPackage ../../development/interpreters/erlang/generic-builder.nix args;
    in
      callPackage drv {
        mkDerivation = pkgs.makeOverridable builder;
      };

  callElixir = drv: args:
    let
      builder = callPackage ../../development/interpreters/elixir/generic-builder.nix args;
    in
      callPackage drv {
        mkDerivation = pkgs.makeOverridable builder;
      };

}