nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 113 lines 4.1 kB view raw
1{ 2 lib, 3 buildGraalvmNativeImage, 4 fetchurl, 5 writeScript, 6 installShellFiles, 7}: 8 9buildGraalvmNativeImage (finalAttrs: { 10 pname = "babashka-unwrapped"; 11 version = "1.12.209"; 12 13 src = fetchurl { 14 url = "https://github.com/babashka/babashka/releases/download/v${finalAttrs.version}/babashka-${finalAttrs.version}-standalone.jar"; 15 sha256 = "sha256-Br8e011Iy+fr+MrIIRtcga98VSDKDeyRfgVTPnjBMII="; 16 }; 17 18 nativeBuildInputs = [ installShellFiles ]; 19 20 extraNativeImageBuildArgs = [ 21 "-H:+ReportExceptionStackTraces" 22 "--no-fallback" 23 "--native-image-info" 24 "--enable-preview" 25 ]; 26 27 doInstallCheck = true; 28 29 installCheckPhase = '' 30 runHook preInstallCheck 31 32 $out/bin/bb --version | fgrep '${finalAttrs.version}' 33 $out/bin/bb '(+ 1 2)' | fgrep '3' 34 $out/bin/bb '(vec (dedupe *input*))' <<< '[1 1 1 1 2]' | fgrep '[1 2]' 35 $out/bin/bb '(prn "bépo àê")' | fgrep 'bépo àê' 36 $out/bin/bb '(:out (babashka.process/sh "echo" "ä"))' | fgrep 'ä' 37 $out/bin/bb '(into-array [:f])' 38 39 runHook postInstallCheck 40 ''; 41 42 postInstall = '' 43 installShellCompletion --cmd bb --bash ${./completions/bb.bash} 44 installShellCompletion --cmd bb --zsh ${./completions/bb.zsh} 45 installShellCompletion --cmd bb --fish ${./completions/bb.fish} 46 ''; 47 48 passthru.updateScript = writeScript "update-babashka" '' 49 #!/usr/bin/env nix-shell 50 #!nix-shell -i bash -p curl common-updater-scripts jq libarchive 51 52 set -euo pipefail 53 shopt -s inherit_errexit 54 55 latest_version="$(curl \ 56 ''${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} \ 57 -fsL "https://api.github.com/repos/babashka/babashka/releases/latest" \ 58 | jq -r '.tag_name')" 59 60 if [ "$(update-source-version babashka-unwrapped "''${latest_version/v/}" --print-changes)" = "[]" ]; then 61 # no need to update babashka.clojure-tools when babashka-unwrapped wasn't updated 62 exit 0 63 fi 64 65 clojure_tools_version=$(curl \ 66 -fsL \ 67 "https://github.com/babashka/babashka/releases/download/''${latest_version}/babashka-''${latest_version/v/}-standalone.jar" \ 68 | bsdtar -qxOf - borkdude/deps.clj \ 69 | ${lib.getExe finalAttrs.finalPackage} -I -o -e "(or (some->> *input* (filter #(= '(def version) (take 2 %))) first last last last) (throw (ex-info \"Couldn't find expected '(def version ...)' form in 'borkdude/deps.clj'.\" {})))") 70 71 update-source-version babashka.clojure-tools "$clojure_tools_version" \ 72 --file="pkgs/development/interpreters/babashka/clojure-tools.nix" 73 ''; 74 75 meta = { 76 description = "Clojure babushka for the grey areas of Bash"; 77 longDescription = '' 78 The main idea behind babashka is to leverage Clojure in places where you 79 would be using bash otherwise. 80 81 As one user described it: 82 83 Im quite at home in Bash most of the time, but theres a substantial 84 grey area of things that are too complicated to be simple in bash, but 85 too simple to be worth writing a clj/s script for. Babashka really 86 seems to hit the sweet spot for those cases. 87 88 Goals: 89 90 - Low latency Clojure scripting alternative to JVM Clojure. 91 - Easy installation: grab the self-contained binary and run. No JVM needed. 92 - Familiarity and portability: 93 - Scripts should be compatible with JVM Clojure as much as possible 94 - Scripts should be platform-independent as much as possible. Babashka 95 offers support for linux, macOS and Windows. 96 - Allow interop with commonly used classes like java.io.File and System 97 - Multi-threading support (pmap, future, core.async) 98 - Batteries included (tools.cli, cheshire, ...) 99 - Library support via popular tools like the clojure CLI 100 ''; 101 homepage = "https://github.com/babashka/babashka"; 102 changelog = "https://github.com/babashka/babashka/blob/v${finalAttrs.version}/CHANGELOG.md"; 103 sourceProvenance = with lib.sourceTypes; [ binaryBytecode ]; 104 license = lib.licenses.epl10; 105 mainProgram = "bb"; 106 maintainers = with lib.maintainers; [ 107 bandresen 108 bhougland 109 DerGuteMoritz 110 jlesquembre 111 ]; 112 }; 113})