From 19fca6f48324a6830f72bde513ce976ef49c2025 Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Fri, 26 Feb 2021 11:07:10 -0300 Subject: [PATCH] babashka: sync native-image arguments with upstream This commit syncs the arguments passed to the babashka with upstream: https://github.com/babashka/babashka/blob/77daea7362d8e2562c89c315b1fbcefde6fa56a5/script/compile#L41-L74 The idea here is to enable more features and reduce the number of issues compared to upstream. Also add some tests to ensure everything is working. --- .../interpreters/clojure/babashka.nix | 79 +++++++++++++------ 1 file changed, 57 insertions(+), 22 deletions(-) diff --git a/pkgs/development/interpreters/clojure/babashka.nix b/pkgs/development/interpreters/clojure/babashka.nix index 774e83311b11..43b8fb4c6c4c 100644 --- a/pkgs/development/interpreters/clojure/babashka.nix +++ b/pkgs/development/interpreters/clojure/babashka.nix @@ -17,36 +17,71 @@ stdenv.mkDerivation rec { dontUnpack = true; - LC_ALL = "en_US.UTF-8"; nativeBuildInputs = [ graalvm11-ce glibcLocales ]; + LC_ALL = "en_US.UTF-8"; + BABASHKA_JAR = src; + BABASHKA_BINARY = "bb"; + BABASHKA_XMX = "-J-Xmx4500m"; + buildPhase = '' - native-image \ - -jar ${src} \ - -H:Name=bb \ - ${lib.optionalString stdenv.isDarwin ''-H:-CheckToolchain''} \ - -H:+ReportExceptionStackTraces \ - -J-Dclojure.spec.skip-macros=true \ - -J-Dclojure.compiler.direct-linking=true \ - "-H:IncludeResources=BABASHKA_VERSION" \ - "-H:IncludeResources=SCI_VERSION" \ - -H:ReflectionConfigurationFiles=${reflectionJson} \ - --initialize-at-build-time \ - -H:Log=registerResource: \ - -H:EnableURLProtocols=http,https \ - --enable-all-security-services \ - -H:+JNI \ - --verbose \ - --no-fallback \ - --no-server \ - --report-unsupported-elements-at-runtime \ - "--initialize-at-run-time=org.postgresql.sspi.SSPIClient" \ - "-J-Xmx4500m" + runHook preBuild + + # https://github.com/babashka/babashka/blob/77daea7362d8e2562c89c315b1fbcefde6fa56a5/script/compile + args=("-jar" "$BABASHKA_JAR" + "-H:Name=$BABASHKA_BINARY" + "${lib.optionalString stdenv.isDarwin ''-H:-CheckToolchain''}" + "-H:+ReportExceptionStackTraces" + "-J-Dclojure.spec.skip-macros=true" + "-J-Dclojure.compiler.direct-linking=true" + "-H:IncludeResources=BABASHKA_VERSION" + "-H:IncludeResources=SCI_VERSION" + "-H:ReflectionConfigurationFiles=${reflectionJson}" + "--initialize-at-build-time" + # "-H:+PrintAnalysisCallTree" + # "-H:+DashboardAll" + # "-H:DashboardDump=reports/dump" + # "-H:+DashboardPretty" + # "-H:+DashboardJson" + "-H:Log=registerResource:" + "-H:EnableURLProtocols=http,https,jar" + "--enable-all-security-services" + "-H:+JNI" + "--verbose" + "--no-fallback" + "--no-server" + "--report-unsupported-elements-at-runtime" + "--initialize-at-run-time=org.postgresql.sspi.SSPIClient" + "--native-image-info" + "--verbose" + "-H:ServiceLoaderFeatureExcludeServices=javax.sound.sampled.spi.AudioFileReader" + "-H:ServiceLoaderFeatureExcludeServices=javax.sound.midi.spi.MidiFileReader" + "-H:ServiceLoaderFeatureExcludeServices=javax.sound.sampled.spi.MixerProvider" + "-H:ServiceLoaderFeatureExcludeServices=javax.sound.sampled.spi.FormatConversionProvider" + "-H:ServiceLoaderFeatureExcludeServices=javax.sound.sampled.spi.AudioFileWriter" + "-H:ServiceLoaderFeatureExcludeServices=javax.sound.midi.spi.MidiDeviceProvider" + "-H:ServiceLoaderFeatureExcludeServices=javax.sound.midi.spi.SoundbankReader" + "-H:ServiceLoaderFeatureExcludeServices=javax.sound.midi.spi.MidiFileWriter" + "$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}' + $out/bin/bb '(+ 1 2)' | grep '3' + $out/bin/bb '(vec (dedupe *input*))' <<< '[1 1 1 1 2]' | grep '[1 2]' ''; meta = with lib; {