2021-02-05 17:12:51 +00:00
|
|
|
|
{ lib, stdenv, fetchurl, graalvm11-ce, glibcLocales }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
|
pname = "babashka";
|
2021-09-18 10:52:07 +00:00
|
|
|
|
version = "0.6.1";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
|
|
src = fetchurl {
|
2021-04-25 03:57:28 +00:00
|
|
|
|
url = "https://github.com/babashka/${pname}/releases/download/v${version}/${pname}-${version}-standalone.jar";
|
2021-09-18 10:52:07 +00:00
|
|
|
|
sha256 = "sha256-s0fZzx/sEAUwXY2cx2ODDhwIrJb5LykFgHBcscsZQO0=";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
dontUnpack = true;
|
|
|
|
|
|
2020-11-06 00:33:48 +00:00
|
|
|
|
nativeBuildInputs = [ graalvm11-ce glibcLocales ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
2021-03-09 03:18:52 +00:00
|
|
|
|
LC_ALL = "en_US.UTF-8";
|
|
|
|
|
BABASHKA_JAR = src;
|
|
|
|
|
BABASHKA_BINARY = "bb";
|
|
|
|
|
BABASHKA_XMX = "-J-Xmx4500m";
|
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
|
buildPhase = ''
|
2021-03-09 03:18:52 +00:00
|
|
|
|
runHook preBuild
|
|
|
|
|
|
2021-09-18 10:52:07 +00:00
|
|
|
|
# https://github.com/babashka/babashka/blob/v0.6.1/script/compile#L41-L52
|
2021-03-09 03:18:52 +00:00
|
|
|
|
args=("-jar" "$BABASHKA_JAR"
|
2021-10-04 12:37:57 +00:00
|
|
|
|
"-H:CLibraryPath=${graalvm11-ce.lib}/lib"
|
2021-09-18 10:52:07 +00:00
|
|
|
|
# Required to build babashka on darwin. Do not remove.
|
|
|
|
|
"${lib.optionalString stdenv.isDarwin "-H:-CheckToolchain"}"
|
2021-03-09 03:18:52 +00:00
|
|
|
|
"-H:Name=$BABASHKA_BINARY"
|
|
|
|
|
"-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
|
2020-04-24 23:36:52 +00:00
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
installPhase = ''
|
2021-03-09 03:18:52 +00:00
|
|
|
|
runHook preInstall
|
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
|
mkdir -p $out/bin
|
|
|
|
|
cp bb $out/bin/bb
|
2021-03-09 03:18:52 +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-24 23:36:52 +00:00
|
|
|
|
'';
|
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
|
description = "A Clojure babushka for the grey areas of Bash";
|
|
|
|
|
longDescription = ''
|
2020-05-29 06:06:01 +00:00
|
|
|
|
The main idea behind babashka is to leverage Clojure in places where you
|
2020-04-24 23:36:52 +00:00
|
|
|
|
would be using bash otherwise.
|
|
|
|
|
|
|
|
|
|
As one user described it:
|
|
|
|
|
|
2020-05-29 06:06:01 +00: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-24 23:36:52 +00: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-29 06:06:01 +00:00
|
|
|
|
- Scripts should be platform-independent as much as possible. Babashka
|
2020-04-24 23:36:52 +00: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
|
|
|
|
|
'';
|
2021-06-01 10:57:12 +00:00
|
|
|
|
homepage = "https://github.com/babashka/babashka";
|
2021-09-18 10:52:07 +00:00
|
|
|
|
changelog = "https://github.com/babashka/babashka/blob/v${version}/CHANGELOG.md";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
license = licenses.epl10;
|
2020-11-06 00:33:48 +00:00
|
|
|
|
platforms = graalvm11-ce.meta.platforms;
|
2021-06-01 10:57:12 +00:00
|
|
|
|
maintainers = with maintainers; [
|
|
|
|
|
bandresen
|
|
|
|
|
bhougland
|
|
|
|
|
DerGuteMoritz
|
|
|
|
|
jlesquembre
|
|
|
|
|
thiagokokada
|
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
};
|
|
|
|
|
}
|