2021-05-28 09:39:13 +00:00
|
|
|
{ pkgs
|
|
|
|
, lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, erlang
|
|
|
|
, makeWrapper
|
|
|
|
, coreutils
|
|
|
|
, curl
|
|
|
|
, bash
|
|
|
|
, debugInfo ? false
|
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
{ baseName ? "elixir"
|
|
|
|
, version
|
|
|
|
, minimumOTPVersion
|
|
|
|
, sha256 ? null
|
|
|
|
, rev ? "v${version}"
|
|
|
|
, src ? fetchFromGitHub { inherit rev sha256; owner = "elixir-lang"; repo = "elixir"; }
|
2023-07-15 17:15:38 +00:00
|
|
|
, escriptPath ? "lib/elixir/generate_app.escript"
|
2020-04-24 23:36:52 +00:00
|
|
|
} @ args:
|
|
|
|
|
|
|
|
let
|
2021-02-05 17:12:51 +00:00
|
|
|
inherit (lib) getVersion versionAtLeast optional;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
in
|
2021-05-28 09:39:13 +00:00
|
|
|
assert versionAtLeast (getVersion erlang) minimumOTPVersion;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-05-28 09:39:13 +00:00
|
|
|
stdenv.mkDerivation ({
|
2022-03-10 19:12:11 +00:00
|
|
|
pname = "${baseName}";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-05-28 09:39:13 +00:00
|
|
|
inherit src version debugInfo;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-05-28 09:39:13 +00:00
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
|
|
|
buildInputs = [ erlang ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-05-28 09:39:13 +00:00
|
|
|
LANG = "C.UTF-8";
|
|
|
|
LC_TYPE = "C.UTF-8";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-05-28 09:39:13 +00:00
|
|
|
buildFlags = optional debugInfo "ERL_COMPILER_OPTIONS=debug_info";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-05-28 09:39:13 +00:00
|
|
|
preBuild = ''
|
2023-07-15 17:15:38 +00:00
|
|
|
patchShebangs ${escriptPath} || true
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-05-28 09:39:13 +00:00
|
|
|
substituteInPlace Makefile \
|
|
|
|
--replace "/usr/local" $out
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-05-28 09:39:13 +00:00
|
|
|
postFixup = ''
|
|
|
|
# Elixir binaries are shell scripts which run erl. Add some stuff
|
|
|
|
# to PATH so the scripts can run without problems.
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-05-28 09:39:13 +00:00
|
|
|
for f in $out/bin/*; do
|
2023-08-04 22:07:22 +00:00
|
|
|
b=$(basename $f)
|
2021-05-28 09:39:13 +00:00
|
|
|
if [ "$b" = mix ]; then continue; fi
|
|
|
|
wrapProgram $f \
|
|
|
|
--prefix PATH ":" "${lib.makeBinPath [ erlang coreutils curl bash ]}"
|
|
|
|
done
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-05-28 09:39:13 +00:00
|
|
|
substituteInPlace $out/bin/mix \
|
2023-08-04 22:07:22 +00:00
|
|
|
--replace "/usr/bin/env elixir" "${coreutils}/bin/env $out/bin/elixir"
|
2021-05-28 09:39:13 +00:00
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-05-28 09:39:13 +00:00
|
|
|
pos = builtins.unsafeGetAttrPos "sha256" args;
|
|
|
|
meta = with lib; {
|
|
|
|
homepage = "https://elixir-lang.org/";
|
|
|
|
description = "A functional, meta-programming aware language built on top of the Erlang VM";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-05-28 09:39:13 +00:00
|
|
|
longDescription = ''
|
|
|
|
Elixir is a functional, meta-programming aware language built on
|
|
|
|
top of the Erlang VM. It is a dynamic language with flexible
|
|
|
|
syntax and macro support that leverages Erlang's abilities to
|
|
|
|
build concurrent, distributed and fault-tolerant applications
|
|
|
|
with hot code upgrades.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2021-05-28 09:39:13 +00:00
|
|
|
license = licenses.epl10;
|
|
|
|
platforms = platforms.unix;
|
|
|
|
maintainers = teams.beam.members;
|
|
|
|
};
|
|
|
|
})
|