2021-01-23 13:15:07 +00:00
|
|
|
|
{ lib, stdenv, fetchurl, graalvm11-ce, glibcLocales }:
|
2020-04-04 22:20:32 +01:00
|
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
|
pname = "babashka";
|
2021-02-14 13:32:25 +00:00
|
|
|
|
version = "0.2.10";
|
2020-04-04 22:20:32 +01:00
|
|
|
|
|
|
|
|
|
reflectionJson = fetchurl {
|
|
|
|
|
name = "reflection.json";
|
|
|
|
|
url = "https://github.com/borkdude/${pname}/releases/download/v${version}/${pname}-${version}-reflection.json";
|
2021-02-14 13:32:25 +00:00
|
|
|
|
sha256 = "1c7f0z1hi0vcfz532r3fhr4c64jjqppf94idpa1jziz1dljkwk85";
|
2020-04-04 22:20:32 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
|
url = "https://github.com/borkdude/${pname}/releases/download/v${version}/${pname}-${version}-standalone.jar";
|
2021-02-14 13:32:25 +00:00
|
|
|
|
sha256 = "0j6k3vmdljf3bjmj5dywhxjmxcs1axscc8dlnw94g5rwf9bin0dn";
|
2020-04-04 22:20:32 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
dontUnpack = true;
|
|
|
|
|
|
2020-11-05 06:11:54 +00:00
|
|
|
|
nativeBuildInputs = [ graalvm11-ce glibcLocales ];
|
2020-04-04 22:20:32 +01:00
|
|
|
|
|
2021-02-26 14:07:10 +00:00
|
|
|
|
LC_ALL = "en_US.UTF-8";
|
|
|
|
|
BABASHKA_JAR = src;
|
|
|
|
|
BABASHKA_BINARY = "bb";
|
|
|
|
|
BABASHKA_XMX = "-J-Xmx4500m";
|
|
|
|
|
|
2020-04-04 22:20:32 +01:00
|
|
|
|
buildPhase = ''
|
2021-02-26 14:07:10 +00:00
|
|
|
|
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
|
2020-04-04 22:20:32 +01:00
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
installPhase = ''
|
2021-02-26 14:07:10 +00:00
|
|
|
|
runHook preInstall
|
|
|
|
|
|
2020-04-04 22:20:32 +01:00
|
|
|
|
mkdir -p $out/bin
|
|
|
|
|
cp bb $out/bin/bb
|
2021-02-26 14:07:10 +00:00
|
|
|
|
|
|
|
|
|
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]'
|
2020-04-04 22:20:32 +01:00
|
|
|
|
'';
|
|
|
|
|
|
2021-01-23 13:15:07 +00:00
|
|
|
|
meta = with lib; {
|
2020-04-04 22:20:32 +01:00
|
|
|
|
description = "A Clojure babushka for the grey areas of Bash";
|
|
|
|
|
longDescription = ''
|
2020-05-20 22:30:06 +01:00
|
|
|
|
The main idea behind babashka is to leverage Clojure in places where you
|
2020-04-04 22:20:32 +01:00
|
|
|
|
would be using bash otherwise.
|
|
|
|
|
|
|
|
|
|
As one user described it:
|
|
|
|
|
|
2020-05-20 22:30:06 +01:00
|
|
|
|
I’m quite at home in Bash most of the time, but there’s a substantial
|
|
|
|
|
grey area of things that are too complicated to be simple in bash, but
|
|
|
|
|
too simple to be worth writing a clj/s script for. Babashka really
|
2020-04-04 22:20:32 +01:00
|
|
|
|
seems to hit the sweet spot for those cases.
|
|
|
|
|
|
|
|
|
|
Goals:
|
|
|
|
|
|
|
|
|
|
- Low latency Clojure scripting alternative to JVM Clojure.
|
|
|
|
|
- Easy installation: grab the self-contained binary and run. No JVM needed.
|
|
|
|
|
- Familiarity and portability:
|
|
|
|
|
- Scripts should be compatible with JVM Clojure as much as possible
|
2020-05-20 22:30:06 +01:00
|
|
|
|
- Scripts should be platform-independent as much as possible. Babashka
|
2020-04-04 22:20:32 +01:00
|
|
|
|
offers support for linux, macOS and Windows.
|
|
|
|
|
- Allow interop with commonly used classes like java.io.File and System
|
|
|
|
|
- Multi-threading support (pmap, future, core.async)
|
|
|
|
|
- Batteries included (tools.cli, cheshire, ...)
|
|
|
|
|
- Library support via popular tools like the clojure CLI
|
|
|
|
|
'';
|
|
|
|
|
homepage = "https://github.com/borkdude/babashka";
|
|
|
|
|
license = licenses.epl10;
|
2020-11-05 06:11:54 +00:00
|
|
|
|
platforms = graalvm11-ce.meta.platforms;
|
2020-05-02 15:44:25 +01:00
|
|
|
|
maintainers = with maintainers; [ bandresen bhougland DerGuteMoritz jlesquembre ];
|
2020-04-04 22:20:32 +01:00
|
|
|
|
};
|
|
|
|
|
}
|