babashka: use buildGraalvmNativeImage

This commit is contained in:
Thiago Kenji Okada 2021-11-23 11:58:32 -03:00
parent 1415e30830
commit 052fb6a228

View File

@ -1,6 +1,6 @@
{ lib, stdenv, fetchurl, graalvm11-ce, glibcLocales, writeScript }:
{ lib, buildGraalvmNativeImage, fetchurl, writeScript }:
stdenv.mkDerivation rec {
buildGraalvmNativeImage rec {
pname = "babashka";
version = "0.6.5";
@ -9,48 +9,14 @@ stdenv.mkDerivation rec {
sha256 = "sha256-72D/HzDIxkGD4zTPE9gHf/uFtboLbNnT7CTslSlAqjc=";
};
dontUnpack = true;
executable = "bb";
nativeBuildInputs = [ graalvm11-ce glibcLocales ];
LC_ALL = "en_US.UTF-8";
BABASHKA_JAR = src;
BABASHKA_BINARY = "bb";
BABASHKA_XMX = "-J-Xmx4500m";
buildPhase = ''
runHook preBuild
# https://github.com/babashka/babashka/blob/v0.6.2/script/compile#L41-L52
args=("-jar" "$BABASHKA_JAR"
"-H:CLibraryPath=${graalvm11-ce.lib}/lib"
# Required to build babashka on darwin. Do not remove.
"${lib.optionalString stdenv.isDarwin "-H:-CheckToolchain"}"
"-H:Name=$BABASHKA_BINARY"
extraNativeImageBuildArgs = [
"-H:+ReportExceptionStackTraces"
# "-H:+PrintAnalysisCallTree"
# "-H:+DashboardAll"
# "-H:DashboardDump=reports/dump"
# "-H:+DashboardPretty"
# "-H:+DashboardJson"
"--verbose"
"--no-fallback"
"--native-image-info"
"$BABASHKA_XMX")
native-image ''${args[@]}
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p $out/bin
cp bb $out/bin/bb
runHook postInstall
'';
];
installCheckPhase = ''
$out/bin/bb --version | grep '${version}'
@ -102,7 +68,6 @@ stdenv.mkDerivation rec {
homepage = "https://github.com/babashka/babashka";
changelog = "https://github.com/babashka/babashka/blob/v${version}/CHANGELOG.md";
license = licenses.epl10;
platforms = graalvm11-ce.meta.platforms;
maintainers = with maintainers; [
bandresen
bhougland