From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alex Vong Subject: [PATCH] gnu: Add clojure. Date: Wed, 24 Feb 2016 13:03:54 +0800 Message-ID: <87povm66o5.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:59599) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYRcK-0008JC-3K for guix-devel@gnu.org; Wed, 24 Feb 2016 00:04:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aYRcF-00024S-Vu for guix-devel@gnu.org; Wed, 24 Feb 2016 00:04:04 -0500 Received: from mail-pa0-x22b.google.com ([2607:f8b0:400e:c03::22b]:36223) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYRcE-000236-LL for guix-devel@gnu.org; Wed, 24 Feb 2016 00:03:59 -0500 Received: by mail-pa0-x22b.google.com with SMTP id yy13so5700041pab.3 for ; Tue, 23 Feb 2016 21:03:58 -0800 (PST) List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: guix-devel@gnu.org --=-=-= Content-Type: text/plain Hi everyone, This patch adds clojure to guix. I have been interested in clojure's syntax for vector [] and hash-map {} for a while, after watching the introduction of clojure to lisper video. So, I decide to package it for guix! Note that I follow the example in ldc and download tarballs needed to run the tests. I have also used pandoc to build markdown files to html. Things I want to do but don't know if I should: Should I add old version of clojure as well? Also, I have tried further compile the jar to native executable using gcj. I think it works although offically gcj supports up to java 1.5 while clojure is written using java 1.6. The native executable takes 0.5s to 0.6s to start while time java -cp "$HOME/.guix-profile/share/java/clojure-1.8.0.jar" \ clojure.main --help' takes 1 to 1.2 s to start on my laptop. Should we provide clojure-gcj package? Cheers, Alex --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: inline; filename=0001-gnu-Add-clojure.patch Content-Transfer-Encoding: quoted-printable >From 4afe3af6cbc36956a6c9c16d76b52499ffc4a8c2 Mon Sep 17 00:00:00 2001 From: Alex Vong Date: Wed, 24 Feb 2016 12:43:36 +0800 Subject: [PATCH] gnu: Add clojure. * gnu/packages/java.scm (clojure): New variable. --- gnu/packages/java.scm | 202 ++++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 202 insertions(+) diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm index ee987fc..367e392 100644 --- a/gnu/packages/java.scm +++ b/gnu/packages/java.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright =C2=A9 2015 Ricardo Wurmus ;;; Copyright =C2=A9 2016 Leo Famulari +;;; Copyright =C2=A9 2016 Alex Vong ;;; ;;; This file is part of GNU Guix. ;;; @@ -39,6 +40,7 @@ #:use-module (gnu packages ghostscript) ;lcms #:use-module (gnu packages gnome) #:use-module (gnu packages gtk) + #:use-module (gnu packages haskell) #:use-module (gnu packages image) #:use-module (gnu packages linux) ;alsa #:use-module (gnu packages wget) @@ -133,6 +135,206 @@ is implemented.") license:mpl2.0 license:lgpl2.1+)))) =20 +(define-public clojure-1.8 + (package + (name "clojure") + (version "1.8.0") + (source + (origin + (method url-fetch) + (uri + (string-append "http://repo1.maven.org/maven2/org/clojure/clojure/" + version "/clojure-" version ".zip")) + (sha256 + (base32 "1nip095fz5c492sw15skril60i1vd21ibg6szin4jcvyy3xr6cym")))) + (build-system gnu-build-system) + (arguments + `(#:modules + ((guix build gnu-build-system) + (guix build utils) + (ice-9 ftw) + (ice-9 regex) + (srfi srfi-1) + (srfi srfi-26)) + #:phases + (modify-phases %standard-phases + (delete 'configure) + (replace 'unpack + (lambda _ + (and (mkdir "clojure/") + (zero? (system* "unzip" + "-d" "clojure/" + (assoc-ref %build-inputs "source"))) + (chdir "clojure/")))) + (add-after 'unpack 'remove-jar + ;; Remove the distributed jar binaries. + (lambda _ + (for-each delete-file + (find-files "./" ".*\\.jar")) + #t)) + (add-after 'remove-jar 'unpack-submodule-sources + (lambda* (#:key inputs #:allow-other-keys) + (let ((unpack + (lambda (src-name) + (and (mkdir src-name) + (with-directory-excursion src-name + (zero? (system* "tar" + "zxvf" + (assoc-ref inputs src-name) + "--strip-components=3D1")))))) + (copy (lambda (src-name) + (copy-recursively + (string-append src-name "/src/main/clojure/") + (string-append "clojure-" ,version "/src/clj/"= ))))) + (every (lambda (src) + (begin (unpack src) + (copy src))) + '("data-generators-src" "java-classpath-src" + "test-check-src" "test-generative-src" + "tools-namespace-src" "tools-reader-src"))))) + (replace 'build + (lambda* (#:key inputs outputs #:allow-other-keys) + (setenv "JAVA_HOME" (assoc-ref inputs "jdk")) + (chdir (string-append "clojure-" ,version)) + (zero? (system* "ant" "jar")))) + (add-after 'build 'build-doc + (lambda* (#:key inputs outputs #:allow-other-keys) + (let* ((markdown-ext-regex "(.*)\\.(md|markdown|txt)") + (markdown->html (lambda (src-name) + (zero? (system* + "pandoc" + "-o" (regexp-substitute/glob= al + #f + markdown-ext-regex + src-name + 1 ".html") + "-f" "markdown_github" + "-t" "html" + src-name))))) + (every markdown->html (find-files "./" markdown-ext-regex))= ))) + (replace 'check + (lambda* (#:key inputs outputs #:allow-other-keys) + (setenv "JAVA_HOME" (assoc-ref inputs "jdk")) + (zero? (system* "ant" "test")))) + (replace 'install + (lambda* (#:key outputs #:allow-other-keys) + (let ((java-dir (string-append (assoc-ref outputs "out") + "/share/java/"))) + ;; Do not install clojure.jar to avoid collisions. + (install-file (string-append "clojure-" ,version ".jar") + java-dir) + #t))) + (add-after 'install 'install-doc + (lambda* (#:key outputs #:allow-other-keys) + (let ((doc-dir (string-append (assoc-ref outputs "out") + "/share/doc/clojure/")) + (copy-file-to-dir (lambda (file dir) + (copy-file file (string-append dir + file= ))))) + (for-each delete-file + (find-files "doc/clojure/" ".*\\.(md|markdown|txt= )")) + (copy-recursively "doc/clojure/" doc-dir) + (for-each (cut copy-file-to-dir <> doc-dir) + (filter (cut string-match ".*\\.(html|txt)" <>) + (scandir "./"))) + #t)))))) + (native-inputs + `(("ant" ,ant) + ("ghc-pandoc" ,ghc-pandoc) + ("jdk" ,icedtea "jdk") + ("unzip" ,unzip) + ("data-generators-src" + ;; The native-inputs below are needed to run the tests. + ,(let ((version "0.1.2")) + (origin + (method url-fetch) + (uri (string-append + "https://github.com" + "/clojure/data.generators/archive/data.generators-" + version ".tar.gz")) + (sha256 + (base32 + "0kki093jp4ckwxzfnw8ylflrfqs8b1i1wi9iapmwcsy328dmgzp1"))))) + ("java-classpath-src" + ,(let ((version "0.2.3")) + (origin + (method url-fetch) + (uri + (string-append "https://github.com" + "/clojure/java.classpath/archive/java.classpa= th-" + version ".tar.gz")) + (sha256 + (base32 + "0sjymly9xh1lkvwn5ygygpsfwz4dabblnlq0c9bx76rkvq62fyng"))))) + ("test-check-src" + ,(let ((version "0.9.0")) + (origin + (method url-fetch) + (uri + (string-append "https://github.com" + "/clojure/test.check/archive/test.check-" + version ".tar.gz")) + (sha256 + (base32 + "0p0mnyhr442bzkz0s4k5ra3i6l5lc7kp6ajaqkkyh4c2k5yck1md"))))) + ("test-generative-src" + ,(let ((version "0.5.2")) + (origin + (method url-fetch) + (uri (string-append + "https://github.com" + "/clojure/test.generative/archive/test.generative-" + version ".tar.gz")) + (sha256 + (base32 + "1pjafy1i7yblc7ixmcpfq1lfbyf3jaljvkgrajn70sws9xs7a9f8"))))) + ("tools-namespace-src" + ,(let ((version "0.2.11")) + (origin + (method url-fetch) + (uri (string-append + "https://github.com" + "/clojure/tools.namespace/archive/tools.namespace-" + version ".tar.gz")) + (sha256 + (base32 + "10baak8v0hnwz2hr33bavshm7y49mmn9zsyyms1dwjz45p5ymhy0"))))) + ("tools-reader-src" + ,(let ((version "0.10.0")) + (origin + (method url-fetch) + (uri + (string-append "https://github.com" + "/clojure/tools.reader/archive/tools.reader-" + version ".tar.gz")) + (sha256 + (base32 + "09i3lzbhr608h76mhdjm3932gg9xi8sflscla3c5f0v1nkc28cnr")))))= )) + (home-page "https://clojure.org/") + (synopsis "Lisp dialect running on the JVM") + (description "Clojure is a dynamic, general-purpose programming langua= ge, +combining the approachability and interactive development of a scripting +language with an efficient and robust infrastructure for multithreaded +programming. Clojure is a compiled language, yet remains completely dynamic +=E2=80=93 every feature supported by Clojure is supported at runtime. Cloj= ure 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 philos= ophy +and a powerful macro system. Clojure is predominantly a functional program= ming +language, and features a rich set of immutable, persistent data structures. +When mutable state is needed, Clojure offers a software transactional memo= ry +system and reactive Agent system that ensure clean, correct, multithreaded +designs.") + ;; Clojure is licensed under EPL1.0 + ;; ASM bytecode manipulation library is licensed under BSD-3 + ;; Guava Murmur3 hash implementation is licensed under under APL2.0 + ;; + ;; See readme.html or readme.txt for details. + (license (list license:epl1.0 + license:bsd-3 + license:asl2.0)))) + (define-public ant (package (name "ant") --=20 2.6.3 --=-=-=--