diff options
author | Alyssa Ross <hi@alyssa.is> | 2023-08-08 16:04:42 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2023-08-13 06:35:37 +0000 |
commit | 12aaa58dac35800b5b7d77f81cf2a87c21ee55da (patch) | |
tree | be0add9e5c22a85d20b5d78206aa74f956eb2a1b /nixpkgs/pkgs/development/interpreters/babashka | |
parent | 45892a5591202f75a1c2f1ca7c62a92c7566e3c5 (diff) | |
parent | 5a8e9243812ba528000995b294292d3b5e120947 (diff) | |
download | nixlib-12aaa58dac35800b5b7d77f81cf2a87c21ee55da.tar nixlib-12aaa58dac35800b5b7d77f81cf2a87c21ee55da.tar.gz nixlib-12aaa58dac35800b5b7d77f81cf2a87c21ee55da.tar.bz2 nixlib-12aaa58dac35800b5b7d77f81cf2a87c21ee55da.tar.lz nixlib-12aaa58dac35800b5b7d77f81cf2a87c21ee55da.tar.xz nixlib-12aaa58dac35800b5b7d77f81cf2a87c21ee55da.tar.zst nixlib-12aaa58dac35800b5b7d77f81cf2a87c21ee55da.zip |
Merge branch 'nixos-unstable' of https://github.com/NixOS/nixpkgs
Conflicts: nixpkgs/pkgs/applications/window-managers/sway/default.nix nixpkgs/pkgs/build-support/go/module.nix nixpkgs/pkgs/build-support/rust/build-rust-package/default.nix nixpkgs/pkgs/development/libraries/mesa/default.nix nixpkgs/pkgs/servers/dict/dictd-db.nix Link: https://gitlab.freedesktop.org/xkeyboard-config/xkeyboard-config/-/issues/391
Diffstat (limited to 'nixpkgs/pkgs/development/interpreters/babashka')
-rw-r--r-- | nixpkgs/pkgs/development/interpreters/babashka/default.nix | 99 | ||||
-rw-r--r-- | nixpkgs/pkgs/development/interpreters/babashka/wrapped.nix | 35 |
2 files changed, 134 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/interpreters/babashka/default.nix b/nixpkgs/pkgs/development/interpreters/babashka/default.nix new file mode 100644 index 000000000000..68f3bed2080d --- /dev/null +++ b/nixpkgs/pkgs/development/interpreters/babashka/default.nix @@ -0,0 +1,99 @@ +{ lib +, buildGraalvmNativeImage +, graalvmCEPackages +, removeReferencesTo +, fetchurl +, writeScript +}: + +buildGraalvmNativeImage rec { + pname = "babashka-unwrapped"; + version = "1.3.181"; + + src = fetchurl { + url = "https://github.com/babashka/babashka/releases/download/v${version}/babashka-${version}-standalone.jar"; + sha256 = "sha256-NzchlHRxOCSyUf9U0Jv8h4bgKd2Jwp+LmxIfeV8+8+M="; + }; + + graalvmDrv = graalvmCEPackages.graalvm19-ce; + + executable = "bb"; + + nativeBuildInputs = [ removeReferencesTo ]; + + extraNativeImageBuildArgs = [ + "-H:+ReportExceptionStackTraces" + "--no-fallback" + "--native-image-info" + "--enable-preview" + ]; + + doInstallCheck = true; + + 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]' + ''; + + # 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 + # graalvm19-ce anyway. + postInstall = '' + remove-references-to -t ${graalvmDrv} $out/bin/${executable} + ''; + + 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 \ + ''${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} \ + -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/}" + ''; + + meta = with lib; { + description = "A Clojure babushka for the grey areas of Bash"; + longDescription = '' + The main idea behind babashka is to leverage Clojure in places where you + would be using bash otherwise. + + As one user described it: + + 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 + 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 + - 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 + ''; + homepage = "https://github.com/babashka/babashka"; + changelog = "https://github.com/babashka/babashka/blob/v${version}/CHANGELOG.md"; + sourceProvenance = with sourceTypes; [ binaryBytecode ]; + license = licenses.epl10; + maintainers = with maintainers; [ + bandresen + bhougland + DerGuteMoritz + jlesquembre + thiagokokada + ]; + }; +} diff --git a/nixpkgs/pkgs/development/interpreters/babashka/wrapped.nix b/nixpkgs/pkgs/development/interpreters/babashka/wrapped.nix new file mode 100644 index 000000000000..64c4acff066c --- /dev/null +++ b/nixpkgs/pkgs/development/interpreters/babashka/wrapped.nix @@ -0,0 +1,35 @@ +{ stdenv +, babashka-unwrapped +, clojure +, makeWrapper +, rlwrap + +, jdkBabashka ? clojure.jdk +}: +stdenv.mkDerivation (finalAttrs: { + pname = "babashka"; + inherit (babashka-unwrapped) version meta doInstallCheck installCheckPhase; + + dontUnpack = true; + dontBuild = true; + + nativeBuildInputs = [ makeWrapper ]; + + installPhase = + let unwrapped-bin = "${babashka-unwrapped}/bin/bb"; in + '' + mkdir -p $out/clojure_tools + ln -s -t $out/clojure_tools ${clojure}/*.edn + ln -s -t $out/clojure_tools ${clojure}/libexec/* + + makeWrapper "${babashka-unwrapped}/bin/bb" "$out/bin/bb" \ + --inherit-argv0 \ + --set-default DEPS_CLJ_TOOLS_DIR $out/clojure_tools \ + --set-default JAVA_HOME ${jdkBabashka} + + substituteInPlace $out/bin/bb \ + --replace '"${unwrapped-bin}"' '"${rlwrap}/bin/rlwrap" "${unwrapped-bin}"' + ''; + + passthru.unwrapped = babashka-unwrapped; +}) |