elixir: add stdlib source and fix deterministic builds

This commit is contained in:
Adam C. Stephens
2025-07-08 13:54:59 -04:00
parent 4a0129eb7d
commit 480d93609d

View File

@@ -1,5 +1,4 @@
{
pkgs,
lib,
stdenv,
fetchFromGitHub,
@@ -33,7 +32,7 @@ let
assertMsg
concatStringsSep
getVersion
optional
optionals
optionalString
toInt
versions
@@ -68,11 +67,13 @@ let
"${coreutils}/bin/env $out/bin/elixir"
else
"$out/bin/elixir";
erlc_opts = [ "deterministic" ] ++ optionals debugInfo [ "debug_info" ];
in
assert assertMsg (versionAtLeast (getVersion erlang) minimumOTPVersion) compatibilityMsg;
assert assertMsg maxAssert compatibilityMsg;
stdenv.mkDerivation ({
stdenv.mkDerivation {
pname = "${baseName}";
inherit src version debugInfo;
@@ -80,20 +81,23 @@ stdenv.mkDerivation ({
nativeBuildInputs = [ makeWrapper ];
buildInputs = [ erlang ];
LANG = "C.UTF-8";
LC_TYPE = "C.UTF-8";
ERLC_OPTS =
let
erlc_opts = [ "deterministic" ] ++ optional debugInfo "debug_info";
in
"[${concatStringsSep "," erlc_opts}]";
env = {
LANG = "C.UTF-8";
LC_TYPE = "C.UTF-8";
DESTDIR = placeholder "out";
PREFIX = "/";
ERL_COMPILER_OPTIONS = "[${concatStringsSep "," erlc_opts}]";
};
preBuild = ''
patchShebangs ${escriptPath} || true
'';
substituteInPlace Makefile \
--replace "/usr/local" $out
# copy stdlib source files for LSP access
postInstall = ''
for d in lib/*; do
cp -R "$d/lib" "$out/lib/elixir/$d"
done
'';
postFixup = ''
@@ -144,4 +148,4 @@ stdenv.mkDerivation ({
platforms = platforms.unix;
teams = [ teams.beam ];
};
})
}