@@ -0,0 +1,82 @@
1+{ stdenv, fetchurl, graalvm8 }:
2+
3+with stdenv.lib;
4+stdenv.mkDerivation rec {
5+ pname = "babashka";
6+ version = "0.0.78";
7+
8+ reflectionJson = fetchurl {
9+ name = "reflection.json";
10+ url = "https://github.com/borkdude/${pname}/releases/download/v${version}/${pname}-${version}-reflection.json";
11+ sha256 = "1m1nwdxjsc6bkdzkbsll316ly0c3qxaimjzyfph1220irjxnm7xf";
12+ };
13+
14+ src = fetchurl {
15+ url = "https://github.com/borkdude/${pname}/releases/download/v${version}/${pname}-${version}-standalone.jar";
16+ sha256 = "01w990zk5qjrbnc846snh6na002kdyrlrfnqwg03ibx20g3mr7if";
17+ };
18+
19+ dontUnpack = true;
20+
21+ buildInputs = [ graalvm8 ];
22+
23+ buildPhase = ''
24+ native-image \
25+ -jar ${src} \
26+ -H:Name=bb \
27+ -H:+ReportExceptionStackTraces \
28+ -J-Dclojure.spec.skip-macros=true \
29+ -J-Dclojure.compiler.direct-linking=true \
30+ "-H:IncludeResources=BABASHKA_VERSION" \
31+ "-H:IncludeResources=SCI_VERSION" \
32+ -H:ReflectionConfigurationFiles=${reflectionJson} \
33+ --initialize-at-run-time=java.lang.Math\$RandomNumberGeneratorHolder \
34+ --initialize-at-build-time \
35+ -H:Log=registerResource: \
36+ -H:EnableURLProtocols=http,https \
37+ --enable-all-security-services \
38+ -H:+JNI \
39+ --verbose \
40+ --no-fallback \
41+ --no-server \
42+ --report-unsupported-elements-at-runtime \
43+ "-J-Xmx3g"
44+ '';
45+
46+ installPhase = ''
47+ mkdir -p $out/bin
48+ cp bb $out/bin/bb
49+ '';
50+
51+ meta = with stdenv.lib; {
52+ description = "A Clojure babushka for the grey areas of Bash";
53+ longDescription = ''
54+ The main idea behind babashka is to leverage Clojure in places where you
55+ would be using bash otherwise.
56+
57+ As one user described it:
58+
59+ I’m quite at home in Bash most of the time, but there’s a substantial
60+ grey area of things that are too complicated to be simple in bash, but
61+ too simple to be worth writing a clj/s script for. Babashka really
62+ seems to hit the sweet spot for those cases.
63+
64+ Goals:
65+
66+ - Low latency Clojure scripting alternative to JVM Clojure.
67+ - Easy installation: grab the self-contained binary and run. No JVM needed.
68+ - Familiarity and portability:
69+ - Scripts should be compatible with JVM Clojure as much as possible
70+ - Scripts should be platform-independent as much as possible. Babashka
71+ offers support for linux, macOS and Windows.
72+ - Allow interop with commonly used classes like java.io.File and System
73+ - Multi-threading support (pmap, future, core.async)
74+ - Batteries included (tools.cli, cheshire, ...)
75+ - Library support via popular tools like the clojure CLI
76+ '';
77+ homepage = "https://github.com/borkdude/babashka";
78+ license = licenses.epl10;
79+ platforms = graalvm8.meta.platforms;
80+ maintainers = with maintainers; [ bhougland DerGuteMoritz jlesquembre ];
81+ };
82+}