2023-03-24 00:07:29 +00:00
|
|
|
|
{ lib
|
|
|
|
|
, buildGraalvmNativeImage
|
|
|
|
|
, graalvmCEPackages
|
|
|
|
|
, removeReferencesTo
|
|
|
|
|
, fetchurl
|
2023-07-15 17:15:38 +00:00
|
|
|
|
, writeScript
|
|
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
|
buildGraalvmNativeImage rec {
|
2023-07-15 17:15:38 +00:00
|
|
|
|
pname = "babashka-unwrapped";
|
2023-10-09 19:29:22 +00:00
|
|
|
|
version = "1.3.184";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
|
|
src = fetchurl {
|
2023-07-15 17:15:38 +00:00
|
|
|
|
url = "https://github.com/babashka/babashka/releases/download/v${version}/babashka-${version}-standalone.jar";
|
2023-10-09 19:29:22 +00:00
|
|
|
|
sha256 = "sha256-O3pLELYmuuB+Bf1vHTWQ+u7Ymi3qYiMRpCwvEq+GeBQ=";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
};
|
|
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
|
graalvmDrv = graalvmCEPackages.graalvm-ce;
|
2023-03-24 00:07:29 +00:00
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
|
executable = "bb";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
2023-03-24 00:07:29 +00:00
|
|
|
|
nativeBuildInputs = [ removeReferencesTo ];
|
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
|
extraNativeImageBuildArgs = [
|
|
|
|
|
"-H:+ReportExceptionStackTraces"
|
|
|
|
|
"--no-fallback"
|
|
|
|
|
"--native-image-info"
|
2023-03-24 00:07:29 +00:00
|
|
|
|
"--enable-preview"
|
2021-12-06 16:07:01 +00:00
|
|
|
|
];
|
2021-03-09 03:18:52 +00:00
|
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
|
doInstallCheck = true;
|
|
|
|
|
|
2021-03-09 03:18:52 +00:00
|
|
|
|
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
|
|
|
|
'';
|
|
|
|
|
|
2023-03-24 00:07:29 +00:00
|
|
|
|
# As of v1.2.174, this will remove references to ${graalvmDrv}/conf/chronology,
|
|
|
|
|
# not sure the implications of this but this file is not available in
|
2023-10-09 19:29:22 +00:00
|
|
|
|
# graalvm-ce anyway.
|
2023-03-24 00:07:29 +00:00
|
|
|
|
postInstall = ''
|
|
|
|
|
remove-references-to -t ${graalvmDrv} $out/bin/${executable}
|
|
|
|
|
'';
|
|
|
|
|
|
2021-10-28 06:52:43 +00:00
|
|
|
|
passthru.updateScript = writeScript "update-babashka" ''
|
|
|
|
|
#!/usr/bin/env nix-shell
|
|
|
|
|
#!nix-shell -i bash -p curl common-updater-scripts jq
|
|
|
|
|
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
|
|
readonly latest_version="$(curl \
|
2022-12-28 21:21:41 +00:00
|
|
|
|
''${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} \
|
2021-10-28 06:52:43 +00:00
|
|
|
|
-s "https://api.github.com/repos/babashka/babashka/releases/latest" \
|
|
|
|
|
| jq -r '.tag_name')"
|
|
|
|
|
|
|
|
|
|
# v0.6.2 -> 0.6.2
|
|
|
|
|
update-source-version babashka "''${latest_version/v/}"
|
|
|
|
|
'';
|
|
|
|
|
|
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.
|
|
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
|
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
|
|
|
|
|
- Scripts should be platform-independent as much as possible. Babashka
|
|
|
|
|
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
|
2020-04-24 23:36:52 +00:00
|
|
|
|
'';
|
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";
|
2022-06-16 17:23:12 +00:00
|
|
|
|
sourceProvenance = with sourceTypes; [ binaryBytecode ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
license = licenses.epl10;
|
2021-06-01 10:57:12 +00:00
|
|
|
|
maintainers = with maintainers; [
|
|
|
|
|
bandresen
|
|
|
|
|
bhougland
|
|
|
|
|
DerGuteMoritz
|
|
|
|
|
jlesquembre
|
|
|
|
|
thiagokokada
|
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
};
|
|
|
|
|
}
|