From e88a89ad330743c6be885fef415307c9ff9197cc Mon Sep 17 00:00:00 2001 From: Daiderd Jordan Date: Thu, 8 Jun 2017 01:39:17 +0200 Subject: [PATCH] erlang: use makeOverridable for customizations --- pkgs/development/beam-modules/lib.nix | 36 +++++++++++++------ pkgs/top-level/beam-packages.nix | 50 +++++++-------------------- 2 files changed, 38 insertions(+), 48 deletions(-) diff --git a/pkgs/development/beam-modules/lib.nix b/pkgs/development/beam-modules/lib.nix index 2d0eef09563a..ae2705613f0c 100644 --- a/pkgs/development/beam-modules/lib.nix +++ b/pkgs/development/beam-modules/lib.nix @@ -2,20 +2,36 @@ rec { - /* Uses generic-builder to evaluate provided drv containing OTP-version specific data. + /* 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; + + /* 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; - gargs: arguments passed to the generic-builder, used mostly to customize dependencies; - args: arguments merged into version-specific args, used mostly to enable/disable high-level OTP - features, like ODBC or WX support; + args: arguments merged into version-specific args, used mostly to customize + dependencies; - Please note that "mkDerivation" defined here is the one called from R16.nix and similar files. + 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: gargs: args: pkgs.callPackage drv ( - let builder = pkgs.callPackage ../../development/interpreters/erlang/generic-builder.nix gargs; - in { - mkDerivation = a: builder (a // args); - }); + callErlang = drv: args: + let + builder = callPackage ../../development/interpreters/erlang/generic-builder.nix args; + in + callPackage drv { + mkDerivation = pkgs.makeOverridable builder; + }; } diff --git a/pkgs/top-level/beam-packages.nix b/pkgs/top-level/beam-packages.nix index 94f3028ddb31..547e650a636d 100644 --- a/pkgs/top-level/beam-packages.nix +++ b/pkgs/top-level/beam-packages.nix @@ -12,54 +12,28 @@ rec { erlang_odbc_javac = erlangR18_odbc_javac; # These are standard Erlang versions, using the generic builder. - erlangR16 = lib.callErlang ../development/interpreters/erlang/R16.nix {} {}; - erlangR16_odbc = lib.callErlang ../development/interpreters/erlang/R16.nix {} { - odbcSupport = true; - }; - erlangR17 = lib.callErlang ../development/interpreters/erlang/R17.nix {} {}; - erlangR17_odbc = lib.callErlang ../development/interpreters/erlang/R17.nix {} { - odbcSupport = true; - }; - erlangR17_javac = lib.callErlang ../development/interpreters/erlang/R17.nix {} { - javacSupport = true; - }; - erlangR17_odbc_javac = lib.callErlang ../development/interpreters/erlang/R17.nix {} { + erlangR16 = lib.callErlang ../development/interpreters/erlang/R16.nix {}; + erlangR16_odbc = erlangR16.override { odbcSupport = true; }; + erlangR17 = lib.callErlang ../development/interpreters/erlang/R17.nix {}; + erlangR17_odbc = erlangR17.override { odbcSupport = true; }; + erlangR17_javac = erlangR17.override { javacSupport = true; }; + erlangR17_odbc_javac = erlangR17.override { javacSupport = true; odbcSupport = true; }; erlangR18 = lib.callErlang ../development/interpreters/erlang/R18.nix { wxGTK = wxGTK30; - } {}; - erlangR18_odbc = lib.callErlang ../development/interpreters/erlang/R18.nix { - wxGTK = wxGTK30; - } { - odbcSupport = true; }; - erlangR18_javac = lib.callErlang ../development/interpreters/erlang/R18.nix { - wxGTK = wxGTK30; - } { - javacSupport = true; - }; - erlangR18_odbc_javac = lib.callErlang ../development/interpreters/erlang/R18.nix { - wxGTK = wxGTK30; - } { + erlangR18_odbc = erlangR18.override { odbcSupport = true; }; + erlangR18_javac = erlangR18.override { javacSupport = true; }; + erlangR18_odbc_javac = erlangR18.override { javacSupport = true; odbcSupport = true; }; erlangR19 = lib.callErlang ../development/interpreters/erlang/R19.nix { wxGTK = wxGTK30; - } {}; - erlangR19_odbc = lib.callErlang ../development/interpreters/erlang/R19.nix { - wxGTK = wxGTK30; - } { - odbcSupport = true; }; - erlangR19_javac = lib.callErlang ../development/interpreters/erlang/R19.nix { - wxGTK = wxGTK30; - } { - javacSupport = true; - }; - erlangR19_odbc_javac = lib.callErlang ../development/interpreters/erlang/R19.nix { - wxGTK = wxGTK30; - } { + erlangR19_odbc = erlangR19.override { odbcSupport = true; }; + erlangR19_javac = erlangR19.override { javacSupport = true; }; + erlangR19_odbc_javac = erlangR19.override { javacSupport = true; odbcSupport = true; };