about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/interpreters/clojure
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/interpreters/clojure')
-rw-r--r--nixpkgs/pkgs/development/interpreters/clojure/babashka.nix84
-rw-r--r--nixpkgs/pkgs/development/interpreters/clojure/clooj.nix30
-rw-r--r--nixpkgs/pkgs/development/interpreters/clojure/default.nix81
3 files changed, 195 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/interpreters/clojure/babashka.nix b/nixpkgs/pkgs/development/interpreters/clojure/babashka.nix
new file mode 100644
index 000000000000..790f8d1ef81b
--- /dev/null
+++ b/nixpkgs/pkgs/development/interpreters/clojure/babashka.nix
@@ -0,0 +1,84 @@
+{ lib, stdenv, fetchurl, graalvm11-ce, glibcLocales }:
+
+with lib;
+stdenv.mkDerivation rec {
+  pname = "babashka";
+  version = "0.2.3";
+
+  reflectionJson = fetchurl {
+    name = "reflection.json";
+    url = "https://github.com/borkdude/${pname}/releases/download/v${version}/${pname}-${version}-reflection.json";
+    sha256 = "0lbdh3v3g3j00bn99bjhjj3gk1q9ks2alpvl9bxc00xpyw86f7z8";
+  };
+
+  src = fetchurl {
+    url = "https://github.com/borkdude/${pname}/releases/download/v${version}/${pname}-${version}-standalone.jar";
+    sha256 = "0vh6k3dkzyk346jjzg6n4mdi65iybrmhb3js9lm73yc3ay2c5dyi";
+  };
+
+  dontUnpack = true;
+
+  LC_ALL = "en_US.UTF-8";
+  nativeBuildInputs = [ graalvm11-ce glibcLocales ];
+
+  buildPhase = ''
+    native-image \
+      -jar ${src} \
+      -H:Name=bb \
+      ${optionalString stdenv.isDarwin ''-H:-CheckToolchain''} \
+      -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 \
+      "--initialize-at-run-time=org.postgresql.sspi.SSPIClient" \
+      "-J-Xmx4500m"
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp bb $out/bin/bb
+  '';
+
+  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/borkdude/babashka";
+    license = licenses.epl10;
+    platforms = graalvm11-ce.meta.platforms;
+    maintainers = with maintainers; [ bandresen bhougland DerGuteMoritz jlesquembre ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/interpreters/clojure/clooj.nix b/nixpkgs/pkgs/development/interpreters/clojure/clooj.nix
new file mode 100644
index 000000000000..57da5e862e99
--- /dev/null
+++ b/nixpkgs/pkgs/development/interpreters/clojure/clooj.nix
@@ -0,0 +1,30 @@
+{ lib, stdenv, fetchurl, jre, makeWrapper }:
+
+let version = "0.4.4"; in
+
+stdenv.mkDerivation {
+  pname = "clooj";
+  inherit version;
+
+  jar = fetchurl {
+    # mirrored as original mediafire.com source does not work without user interaction
+    url = "https://archive.org/download/clooj-0.4.4-standalone/clooj-0.4.4-standalone.jar";
+    sha256 = "0hbc29bg2a86rm3sx9kvj7h7db9j0kbnrb706wsfiyk3zi3bavnd";
+  };
+
+  buildInputs = [ makeWrapper ];
+
+  phases = "installPhase";
+
+  installPhase = ''
+    mkdir -p $out/share/java
+    ln -s $jar $out/share/java/clooj.jar
+    makeWrapper ${jre}/bin/java $out/bin/clooj --add-flags "-jar $out/share/java/clooj.jar"
+  '';
+
+  meta = {
+    description = "A lightweight IDE for Clojure";
+    homepage = "https://github.com/arthuredelstein/clooj";
+    license = lib.licenses.bsd3;
+  };
+}
diff --git a/nixpkgs/pkgs/development/interpreters/clojure/default.nix b/nixpkgs/pkgs/development/interpreters/clojure/default.nix
new file mode 100644
index 000000000000..89db33c5a8c5
--- /dev/null
+++ b/nixpkgs/pkgs/development/interpreters/clojure/default.nix
@@ -0,0 +1,81 @@
+{ lib, stdenv, fetchurl, installShellFiles, jdk, rlwrap, makeWrapper }:
+
+stdenv.mkDerivation rec {
+  pname = "clojure";
+  version = "1.10.2.774";
+
+  src = fetchurl {
+    # https://clojure.org/releases/tools
+    url = "https://download.clojure.org/install/clojure-tools-${version}.tar.gz";
+    sha256 = "0z3j8m9k7prmx6n3kpyhj04pjdg7y0plyxv4kp7789shanr6y4qp";
+  };
+
+  nativeBuildInputs = [
+    installShellFiles
+    makeWrapper
+  ];
+
+  # See https://github.com/clojure/brew-install/blob/1.10.1/src/main/resources/clojure/install/linux-install.sh
+  installPhase =
+    let
+      binPath = lib.makeBinPath [ rlwrap jdk ];
+    in
+    ''
+      runHook preInstall
+
+      clojure_lib_dir=$out
+      bin_dir=$out/bin
+
+      echo "Installing libs into $clojure_lib_dir"
+      install -Dm644 deps.edn "$clojure_lib_dir/deps.edn"
+      install -Dm644 example-deps.edn "$clojure_lib_dir/example-deps.edn"
+      install -Dm644 exec.jar "$clojure_lib_dir/libexec/exec.jar"
+      install -Dm644 clojure-tools-${version}.jar "$clojure_lib_dir/libexec/clojure-tools-${version}.jar"
+
+      echo "Installing clojure and clj into $bin_dir"
+      substituteInPlace clojure --replace PREFIX $out
+      install -Dm755 clojure "$bin_dir/clojure"
+      install -Dm755 clj "$bin_dir/clj"
+
+      wrapProgram $bin_dir/clojure --prefix PATH : $out/bin:${binPath}
+      wrapProgram $bin_dir/clj --prefix PATH : $out/bin:${binPath}
+
+      installManPage clj.1 clojure.1
+
+      runHook postInstall
+    '';
+
+  doInstallCheck = true;
+  installCheckPhase = ''
+    CLJ_CONFIG=$out CLJ_CACHE=$out/libexec $out/bin/clojure \
+      -Spath \
+      -Sverbose \
+      -Scp $out/libexec/clojure-tools-${version}.jar
+  '';
+  meta = with lib; {
+    description = "A Lisp dialect for the JVM";
+    homepage = "https://clojure.org/";
+    license = licenses.epl10;
+    longDescription = ''
+      Clojure is a dynamic programming language that targets the Java
+      Virtual Machine. It is designed to be a general-purpose language,
+      combining the approachability and interactive development of a
+      scripting language with an efficient and robust infrastructure for
+      multithreaded programming. Clojure is a compiled language - it
+      compiles directly to JVM bytecode, yet remains completely
+      dynamic. Every feature supported by Clojure is supported at
+      runtime. Clojure provides easy access to the Java frameworks, with
+      optional type hints and type inference, to ensure that calls to Java
+      can avoid reflection.
+
+      Clojure is a dialect of Lisp, and shares with Lisp the code-as-data
+      philosophy and a powerful macro system. Clojure is predominantly a
+      functional programming language, and features a rich set of immutable,
+      persistent data structures. When mutable state is needed, Clojure
+      offers a software transactional memory system and reactive Agent
+      system that ensure clean, correct, multithreaded designs.
+    '';
+    maintainers = with maintainers; [ jlesquembre thiagokokada ];
+    platforms = platforms.unix;
+  };
+}