Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)

Merge pull request #11651 from gleber/add-erlang-modules

Add erlang modules

+485
+1
lib/maintainers.nix
··· 118 118 gebner = "Gabriel Ebner <gebner@gebner.org>"; 119 119 gfxmonk = "Tim Cuthbertson <tim@gfxmonk.net>"; 120 120 giogadi = "Luis G. Torres <lgtorres42@gmail.com>"; 121 + gleber = "Gleb Peregud <gleber.p@gmail.com>"; 121 122 globin = "Robin Gloster <robin@glob.in>"; 122 123 goibhniu = "Cillian de Róiste <cillian.deroiste@gmail.com>"; 123 124 gridaphobe = "Eric Seidel <eric@seidel.io>";
+65
pkgs/development/erlang-modules/build-erlang.nix
··· 1 + { stdenv, erlang, rebar, openssl, libyaml }: 2 + 3 + { name, version 4 + , buildInputs ? [], erlangDeps ? [] 5 + , postPatch ? "" 6 + , meta ? {} 7 + , ... }@attrs: 8 + 9 + with stdenv.lib; 10 + 11 + stdenv.mkDerivation (attrs // { 12 + name = "${name}-${version}"; 13 + 14 + buildInputs = buildInputs ++ [ erlang rebar openssl libyaml ]; 15 + 16 + postPatch = '' 17 + rm -f rebar 18 + if [ -e "src/${name}.app.src" ]; then 19 + sed -i -e 's/{ *vsn *,[^}]*}/{vsn, "${version}"}/' "src/${name}.app.src" 20 + fi 21 + ${postPatch} 22 + ''; 23 + 24 + configurePhase = let 25 + getDeps = drv: [drv] ++ (map getDeps drv.erlangDeps); 26 + recursiveDeps = uniqList { 27 + inputList = flatten (map getDeps erlangDeps); 28 + }; 29 + in '' 30 + runHook preConfigure 31 + ${concatMapStrings (dep: '' 32 + header "linking erlang dependency ${dep}" 33 + mkdir deps 34 + ln -s "${dep}" "deps/${dep.packageName}" 35 + stopNest 36 + '') recursiveDeps} 37 + runHook postConfigure 38 + ''; 39 + 40 + buildPhase = '' 41 + runHook preBuild 42 + rebar compile 43 + runHook postBuild 44 + ''; 45 + 46 + installPhase = '' 47 + runHook preInstall 48 + for reldir in src ebin priv include; do 49 + [ -e "$reldir" ] || continue 50 + mkdir "$out" 51 + cp -rt "$out" "$reldir" 52 + success=1 53 + done 54 + runHook postInstall 55 + ''; 56 + 57 + meta = { 58 + inherit (erlang.meta) platforms; 59 + } // meta; 60 + 61 + passthru = { 62 + packageName = name; 63 + inherit erlangDeps; 64 + }; 65 + })
+89
pkgs/development/erlang-modules/build-hex.nix
··· 1 + { stdenv, erlang, rebar3, openssl, libyaml, fetchHex, fetchFromGitHub, 2 + rebar3-pc }: 3 + 4 + { name, version, sha256 5 + , hexPkg ? name 6 + , buildInputs ? [], erlangDeps ? [], pluginDeps ? [] 7 + , postPatch ? "" 8 + , compilePorts ? false 9 + , meta ? {} 10 + , ... }@attrs: 11 + 12 + with stdenv.lib; 13 + 14 + stdenv.mkDerivation (attrs // { 15 + name = "${name}-${version}"; 16 + 17 + buildInputs = buildInputs ++ [ erlang rebar3 openssl libyaml ]; 18 + 19 + src = fetchHex { 20 + pkg = hexPkg; 21 + inherit version; 22 + inherit sha256; 23 + }; 24 + 25 + postPatch = '' 26 + rm -f rebar rebar3 27 + if [ -e "src/${name}.app.src" ]; then 28 + sed -i -e 's/{ *vsn *,[^}]*}/{vsn, "${version}"}/' "src/${name}.app.src" 29 + fi 30 + 31 + ${if compilePorts then '' 32 + echo "{plugins, [pc]}." >> rebar.config 33 + '' else ''''} 34 + 35 + ${rebar3.setupRegistry} 36 + 37 + ${postPatch} 38 + ''; 39 + 40 + configurePhase = let 41 + plugins = pluginDeps ++ (if compilePorts then [rebar3-pc] else []); 42 + getDeps = drv: [drv] ++ (map getDeps drv.erlangDeps); 43 + recursiveDeps = unique (flatten (map getDeps erlangDeps)); 44 + recursivePluginsDeps = unique (flatten (map getDeps plugins)); 45 + in '' 46 + runHook preConfigure 47 + ${concatMapStrings (dep: '' 48 + header "linking erlang dependency ${dep}" 49 + ln -s "${dep}" "_build/default/lib/${dep.packageName}" 50 + stopNest 51 + '') recursiveDeps} 52 + ${concatMapStrings (dep: '' 53 + header "linking rebar3 plugins ${dep}" 54 + ln -s "${dep}" "_build/default/plugins/${dep.packageName}" 55 + stopNest 56 + '') recursivePluginsDeps} 57 + runHook postConfigure 58 + ''; 59 + 60 + buildPhase = '' 61 + runHook preBuild 62 + HOME=. rebar3 compile 63 + ${if compilePorts then '' 64 + HOME=. rebar3 pc compile 65 + '' else ''''} 66 + runHook postBuild 67 + ''; 68 + 69 + installPhase = '' 70 + runHook preInstall 71 + mkdir "$out" 72 + for reldir in src ebin priv include; do 73 + fd="_build/default/lib/${name}/$reldir" 74 + [ -d "$fd" ] || continue 75 + cp -Hrt "$out" "$fd" 76 + success=1 77 + done 78 + runHook postInstall 79 + ''; 80 + 81 + meta = { 82 + inherit (erlang.meta) platforms; 83 + } // meta; 84 + 85 + passthru = { 86 + packageName = name; 87 + inherit erlangDeps; 88 + }; 89 + })
+18
pkgs/development/erlang-modules/default.nix
··· 1 + { pkgs }: #? import <nixpkgs> {} }: 2 + 3 + let 4 + callPackage = pkgs.lib.callPackageWith (pkgs // self); 5 + 6 + self = rec { 7 + buildErlang = callPackage ./build-erlang.nix {}; 8 + buildHex = callPackage ./build-hex.nix {}; 9 + 10 + rebar3-pc = callPackage ./hex/rebar3-pc.nix {}; 11 + esqlite = callPackage ./hex/esqlite.nix {}; 12 + goldrush = callPackage ./hex/goldrush.nix {}; 13 + ibrowse = callPackage ./hex/ibrowse.nix {}; 14 + jiffy = callPackage ./hex/jiffy.nix {}; 15 + lager = callPackage ./hex/lager.nix {}; 16 + meck = callPackage ./hex/meck.nix {}; 17 + }; 18 + in self
+8
pkgs/development/erlang-modules/hex/esqlite.nix
··· 1 + { buildHex, rebar3-pc }: 2 + 3 + buildHex { 4 + name = "esqlite"; 5 + version = "0.2.1"; 6 + sha256 = "1296fn1lz4lz4zqzn4dwc3flgkh0i6n4sydg501faabfbv8d3wkr"; 7 + compilePorts = true; 8 + }
+7
pkgs/development/erlang-modules/hex/goldrush.nix
··· 1 + { buildHex, fetchurl }: 2 + 3 + buildHex { 4 + name = "goldrush"; 5 + version = "0.1.7"; 6 + sha256 = "1zjgbarclhh10cpgvfxikn9p2ay63rajq96q1sbz9r9w6v6p8jm9"; 7 + }
+8
pkgs/development/erlang-modules/hex/ibrowse.nix
··· 1 + { buildHex }: 2 + 3 + buildHex { 4 + name = "ibrowse"; 5 + version = "4.2.2"; 6 + sha256 = "1bn0645n95j5zypdsns1w4kgd3q9lz8fj898hg355j5w89scn05q"; 7 + } 8 +
+8
pkgs/development/erlang-modules/hex/jiffy.nix
··· 1 + { buildHex }: 2 + 3 + buildHex { 4 + name = "jiffy"; 5 + version = "0.14.5"; 6 + hexPkg = "barrel_jiffy"; 7 + sha256 = "0iqz8bp0f672c5rfy5dpw9agv2708wzldd00ngbsffglpinlr1wa"; 8 + }
+8
pkgs/development/erlang-modules/hex/lager.nix
··· 1 + { buildHex, goldrush }: 2 + 3 + buildHex { 4 + name = "lager"; 5 + version = "3.0.2"; 6 + sha256 = "0051zj6wfmmvxjn9q0nw8wic13nhbrkyy50cg1lcpdh17qiknzsj"; 7 + erlangDeps = [ goldrush ]; 8 + }
+13
pkgs/development/erlang-modules/hex/meck.nix
··· 1 + { stdenv, buildHex }: 2 + 3 + buildHex { 4 + name = "meck"; 5 + version = "0.8.3"; 6 + sha256 = "1dh2rhks1xly4f49x89vbhsk8fgwkx5zqp0n98mnng8rs1rkigak"; 7 + 8 + meta = { 9 + description = "A mocking framework for Erlang"; 10 + homepage = "https://github.com/eproxus/meck"; 11 + license = stdenv.lib.licenses.apsl20; 12 + }; 13 + }
+7
pkgs/development/erlang-modules/hex/rebar3-pc.nix
··· 1 + { buildHex, goldrush }: 2 + 3 + buildHex { 4 + name = "pc"; 5 + version = "1.1.0"; 6 + sha256 = "1br5xfl4b2z70b6a2ccxppn64jvkqgpmy4y9v81kxzb91z0ss9ma"; 7 + }
+129
pkgs/development/tools/build-managers/rebar3/default.nix
··· 1 + { stdenv, fetchurl, fetchHex, erlang, tree, fetchFromGitHub }: 2 + 3 + 4 + let 5 + version = "3.0.0-beta.4"; 6 + registrySnapshot = import ./registrySnapshot.nix { inherit fetchFromGitHub; }; 7 + setupRegistry = '' 8 + mkdir -p _build/default/{lib,plugins,packages}/ ./.cache/rebar3/hex/default/ 9 + zcat ${registrySnapshot}/registry.ets.gz > .cache/rebar3/hex/default/registry 10 + ''; 11 + # TODO: all these below probably should go into nixpkgs.erlangModules.sources.* 12 + # {erlware_commons, "0.16.0"}, 13 + erlware_commons = fetchHex { 14 + pkg = "erlware_commons"; 15 + version = "0.16.0"; 16 + sha256 = "0kh24d0001390wfx28d0xa874vrsfvjgj41g315vg4hac632krxx"; 17 + }; 18 + # {ssl_verify_hostname, "1.0.5"}, 19 + ssl_verify_hostname = fetchHex { 20 + pkg = "ssl_verify_hostname"; 21 + version = "1.0.5"; 22 + sha256 = "1gzavzqzljywx4l59gvhkjbr1dip4kxzjjz1s4wsn42f2kk13jzj"; 23 + }; 24 + # {certifi, "0.1.1"}, 25 + certifi = fetchHex { 26 + pkg = "certifi"; 27 + version = "0.1.1"; 28 + sha256 = "0afylwqg74gprbg116asz0my2nipmki0512c8mdiq6xdiyjdvlg6"; 29 + }; 30 + # {providers, "1.5.0"}, 31 + providers = fetchHex { 32 + pkg = "providers"; 33 + version = "1.5.0"; 34 + sha256 = "1hc8sp2l1mmx9dfpmh1f8j9hayfg7541rmx05wb9cmvxvih7zyvf"; 35 + }; 36 + # {getopt, "0.8.2"}, 37 + getopt = fetchHex { 38 + pkg = "getopt"; 39 + version = "0.8.2"; 40 + sha256 = "1xw30h59zbw957cyjd8n50hf9y09jnv9dyry6x3avfwzcyrnsvkk"; 41 + }; 42 + # {bbmustache, "1.0.4"}, 43 + bbmustache = fetchHex { 44 + pkg = "bbmustache"; 45 + version = "1.0.4"; 46 + sha256 = "04lvwm7f78x8bys0js33higswjkyimbygp4n72cxz1kfnryx9c03"; 47 + }; 48 + # {relx, "3.8.0"}, 49 + relx = fetchHex { 50 + pkg = "relx"; 51 + version = "3.8.0"; 52 + sha256 = "0y89iirjz3kc1rzkdvc6p3ssmwcm2hqgkklhgm4pkbc14fcz57hq"; 53 + }; 54 + # {cf, "0.2.1"}, 55 + cf = fetchHex { 56 + pkg = "cf"; 57 + version = "0.2.1"; 58 + sha256 = "19d0yvg8wwa57cqhn3vqfvw978nafw8j2rvb92s3ryidxjkrmvms"; 59 + }; 60 + # {cth_readable, "1.1.0"}, 61 + cth_readable = fetchHex { 62 + pkg = "cth_readable"; 63 + version = "1.0.1"; 64 + sha256 = "1cnc4fbypckqllfi5h73rdb24dz576k3177gzvp1kbymwkp1xcz1"; 65 + }; 66 + # {eunit_formatters, "0.2.0"} 67 + eunit_formatters = fetchHex { 68 + pkg = "eunit_formatters"; 69 + version = "0.2.0"; 70 + sha256 = "03kiszlbgzscfd2ns7na6bzbfzmcqdb5cx3p6qy3657jk2fai332"; 71 + }; 72 + 73 + in 74 + stdenv.mkDerivation { 75 + name = "rebar3-${version}"; 76 + 77 + src = fetchurl { 78 + url = "https://github.com/rebar/rebar3/archive/${version}.tar.gz"; 79 + sha256 = "0px66scjdia9aaa5z36qzxb848r56m0k98g0bxw065a2narsh4xy"; 80 + }; 81 + 82 + patches = [ ./hermetic-bootstrap.patch ]; 83 + 84 + buildInputs = [ erlang 85 + tree 86 + ]; 87 + inherit setupRegistry; 88 + 89 + postPatch = '' 90 + echo postPatch 91 + ${setupRegistry} 92 + mkdir -p _build/default/lib/ 93 + cp --no-preserve=mode -R ${erlware_commons} _build/default/lib/erlware_commons 94 + cp --no-preserve=mode -R ${providers} _build/default/lib/providers 95 + cp --no-preserve=mode -R ${getopt} _build/default/lib/getopt 96 + cp --no-preserve=mode -R ${bbmustache} _build/default/lib/bbmustache 97 + cp --no-preserve=mode -R ${certifi} _build/default/lib/certifi 98 + cp --no-preserve=mode -R ${cf} _build/default/lib/cf 99 + cp --no-preserve=mode -R ${cth_readable} _build/default/lib/cth_readable 100 + cp --no-preserve=mode -R ${eunit_formatters} _build/default/lib/eunit_formatters 101 + cp --no-preserve=mode -R ${relx} _build/default/lib/relx 102 + cp --no-preserve=mode -R ${ssl_verify_hostname} _build/default/lib/ssl_verify_hostname 103 + ''; 104 + 105 + buildPhase = '' 106 + HOME=. escript bootstrap 107 + ''; 108 + installPhase = '' 109 + mkdir -p $out/bin 110 + cp rebar3 $out/bin/rebar3 111 + ''; 112 + 113 + meta = { 114 + homepage = "https://github.com/rebar/rebar3"; 115 + description = "rebar 3.0 is an Erlang build tool that makes it easy to compile and test Erlang applications, port drivers and releases."; 116 + 117 + longDescription = '' 118 + rebar is a self-contained Erlang script, so it's easy to distribute or 119 + even embed directly in a project. Where possible, rebar uses standard 120 + Erlang/OTP conventions for project structures, thus minimizing the amount 121 + of build configuration work. rebar also provides dependency management, 122 + enabling application writers to easily re-use common libraries from a 123 + variety of locations (hex.pm, git, hg, and so on). 124 + ''; 125 + 126 + platforms = stdenv.lib.platforms.unix; 127 + maintainers = [ stdenv.lib.maintainers.gleber ]; 128 + }; 129 + }
+34
pkgs/development/tools/build-managers/rebar3/fetch-hex.nix
··· 1 + { stdenv, fetchurl }: 2 + 3 + { pkg, version, sha256 4 + , meta ? {} 5 + }: 6 + 7 + with stdenv.lib; 8 + 9 + stdenv.mkDerivation ({ 10 + name = "hex-source-${pkg}-${version}"; 11 + 12 + src = fetchurl { 13 + url = "https://s3.amazonaws.com/s3.hex.pm/tarballs/${pkg}-${version}.tar"; 14 + inherit sha256; 15 + }; 16 + 17 + phases = [ "unpackPhase" "installPhase" ]; 18 + 19 + unpackCmd = '' 20 + tar -xf $curSrc contents.tar.gz 21 + mkdir contents 22 + tar -C contents -xzf contents.tar.gz 23 + ''; 24 + 25 + installPhase = '' 26 + runHook preInstall 27 + mkdir "$out" 28 + cp -Hrt "$out" . 29 + success=1 30 + runHook postInstall 31 + ''; 32 + 33 + inherit meta; 34 + })
+78
pkgs/development/tools/build-managers/rebar3/hermetic-bootstrap.patch
··· 1 + diff --git a/bootstrap b/bootstrap 2 + index 25bd658..b2a986b 100755 3 + --- a/bootstrap 4 + +++ b/bootstrap 5 + @@ -8,9 +8,6 @@ main(_Args) -> 6 + application:start(asn1), 7 + application:start(public_key), 8 + application:start(ssl), 9 + - inets:start(), 10 + - inets:start(httpc, [{profile, rebar}]), 11 + - set_httpc_options(), 12 + 13 + %% Fetch and build deps required to build rebar3 14 + BaseDeps = [{providers, []} 15 + @@ -33,7 +30,6 @@ main(_Args) -> 16 + 17 + setup_env(), 18 + os:putenv("REBAR_PROFILE", "bootstrap"), 19 + - rebar3:run(["update"]), 20 + {ok, State} = rebar3:run(["compile"]), 21 + reset_env(), 22 + os:putenv("REBAR_PROFILE", ""), 23 + @@ -71,33 +67,7 @@ fetch_and_compile({Name, ErlFirstFiles}, Deps) -> 24 + compile(Name, ErlFirstFiles). 25 + 26 + fetch({pkg, Name, Vsn}, App) -> 27 + - Dir = filename:join([filename:absname("_build/default/lib/"), App]), 28 + - CDN = "https://s3.amazonaws.com/s3.hex.pm/tarballs", 29 + - Package = binary_to_list(<<Name/binary, "-", Vsn/binary, ".tar">>), 30 + - Url = string:join([CDN, Package], "/"), 31 + - case request(Url) of 32 + - {ok, Binary} -> 33 + - {ok, Contents} = extract(Binary), 34 + - ok = erl_tar:extract({binary, Contents}, [{cwd, Dir}, compressed]); 35 + - _ -> 36 + - io:format("Error: Unable to fetch package ~p ~p~n", [Name, Vsn]) 37 + - end. 38 + - 39 + -extract(Binary) -> 40 + - {ok, Files} = erl_tar:extract({binary, Binary}, [memory]), 41 + - {"contents.tar.gz", Contents} = lists:keyfind("contents.tar.gz", 1, Files), 42 + - {ok, Contents}. 43 + - 44 + -request(Url) -> 45 + - case httpc:request(get, {Url, []}, 46 + - [{relaxed, true}], 47 + - [{body_format, binary}], 48 + - rebar) of 49 + - {ok, {{_Version, 200, _Reason}, _Headers, Body}} -> 50 + - {ok, Body}; 51 + - Error -> 52 + - Error 53 + - end. 54 + + ok. 55 + 56 + get_rebar_config() -> 57 + {ok, [[Home]]} = init:get_argument(home), 58 + @@ -109,20 +79,6 @@ get_rebar_config() -> 59 + [] 60 + end. 61 + 62 + -get_http_vars(Scheme) -> 63 + - proplists:get_value(Scheme, get_rebar_config(), []). 64 + - 65 + -set_httpc_options() -> 66 + - set_httpc_options(https_proxy, get_http_vars(https_proxy)), 67 + - set_httpc_options(proxy, get_http_vars(http_proxy)). 68 + - 69 + -set_httpc_options(_, []) -> 70 + - ok; 71 + - 72 + -set_httpc_options(Scheme, Proxy) -> 73 + - {ok, {_, _, Host, Port, _, _}} = http_uri:parse(Proxy), 74 + - httpc:set_options([{Scheme, {{Host, Port}, []}}], rebar). 75 + - 76 + compile(App, FirstFiles) -> 77 + Dir = filename:join(filename:absname("_build/default/lib/"), App), 78 + filelib:ensure_dir(filename:join([Dir, "ebin", "dummy.beam"])),
+8
pkgs/development/tools/build-managers/rebar3/registrySnapshot.nix
··· 1 + { fetchFromGitHub }: 2 + 3 + fetchFromGitHub { 4 + owner = "gleber"; 5 + repo = "hex-pm-registry-snapshots"; 6 + rev = "329ae2b"; 7 + sha256 = "1rs3z8psfvy10mzlfvkdzbflgikcnq08r38kfi0f8p5wvi8f8hmh"; 8 + }
+4
pkgs/top-level/all-packages.nix
··· 5032 5032 erlang_odbc_javac = erlangR18_odbc_javac; 5033 5033 5034 5034 rebar = callPackage ../development/tools/build-managers/rebar { }; 5035 + rebar3 = callPackage ../development/tools/build-managers/rebar3 { }; 5036 + fetchHex = callPackage ../development/tools/build-managers/rebar3/fetch-hex.nix { }; 5037 + 5038 + erlangPackages = callPackage ../development/erlang-modules { }; 5035 5039 5036 5040 elixir = callPackage ../development/interpreters/elixir { }; 5037 5041