2021-02-05 17:12:51 +00:00
|
|
|
|
{ lib, stdenv, fetchurl, graalvm11-ce, glibcLocales }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
|
with lib;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
|
pname = "babashka";
|
2020-11-06 00:33:48 +00:00
|
|
|
|
version = "0.2.3";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
|
|
reflectionJson = fetchurl {
|
|
|
|
|
name = "reflection.json";
|
|
|
|
|
url = "https://github.com/borkdude/${pname}/releases/download/v${version}/${pname}-${version}-reflection.json";
|
2020-11-06 00:33:48 +00:00
|
|
|
|
sha256 = "0lbdh3v3g3j00bn99bjhjj3gk1q9ks2alpvl9bxc00xpyw86f7z8";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
|
url = "https://github.com/borkdude/${pname}/releases/download/v${version}/${pname}-${version}-standalone.jar";
|
2020-11-06 00:33:48 +00:00
|
|
|
|
sha256 = "0vh6k3dkzyk346jjzg6n4mdi65iybrmhb3js9lm73yc3ay2c5dyi";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
dontUnpack = true;
|
|
|
|
|
|
2020-05-03 17:38:23 +00:00
|
|
|
|
LC_ALL = "en_US.UTF-8";
|
2020-11-06 00:33:48 +00:00
|
|
|
|
nativeBuildInputs = [ graalvm11-ce glibcLocales ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
|
native-image \
|
|
|
|
|
-jar ${src} \
|
|
|
|
|
-H:Name=bb \
|
2021-02-05 17:12:51 +00:00
|
|
|
|
${optionalString stdenv.isDarwin ''-H:-CheckToolchain''} \
|
2020-04-24 23:36:52 +00:00
|
|
|
|
-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 \
|
2020-05-03 17:38:23 +00:00
|
|
|
|
"--initialize-at-run-time=org.postgresql.sspi.SSPIClient" \
|
|
|
|
|
"-J-Xmx4500m"
|
2020-04-24 23:36:52 +00:00
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
|
mkdir -p $out/bin
|
|
|
|
|
cp bb $out/bin/bb
|
|
|
|
|
'';
|
|
|
|
|
|
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
|
|
|
|
|
'';
|
|
|
|
|
homepage = "https://github.com/borkdude/babashka";
|
|
|
|
|
license = licenses.epl10;
|
2020-11-06 00:33:48 +00:00
|
|
|
|
platforms = graalvm11-ce.meta.platforms;
|
2020-05-15 21:57:56 +00:00
|
|
|
|
maintainers = with maintainers; [ bandresen bhougland DerGuteMoritz jlesquembre ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
};
|
|
|
|
|
}
|