Clojure now in java-overlay
I recently received commit access to Gentoo’s Java overlay, and so I took the chance to commit my ebuilds for Clojure and Clojure-contrib. This means that Clojure is now a step closer to becoming a standard part of Gentoo.
The following step-by-step guide should help you get started. Note that the following instructions assume you are using the standard Gentoo package management tools. If you use some other system, such as Paludis, you will need to refer to the documentation for your preferred manager about how to add overlays and keyword packages.
In order to get started, you will have to first make sure that the Java overlay is installed on your system.
Installing the Java overlay on Gentoo
In order to install Clojure, you will need to install layman according to the
instructions in the User’s Guide. Be sure to enable the subversion
USE
flag. Once you have layman installed, you should be to execute layman -L
and
see a line similar to the following:
* java-overlay [Subversion] (svn://overlays.gentoo.org/proj/java/java-overlay/
Once layman is installed, add the Java overlay using layman -a java-overlay
.
After a lengthy checkout, you should see the line:
* Successfully added overlay "java-overlay".
Congratulations, you now have the Java overlay installed. Now you can move onto installing Clojure.
Emerging Clojure
With the Java overlay installed, the Clojure and Clojure-contrib ebuilds are now available through portage.
Note that Clojure is currently keyworded ~amd64
and ~x86
. This means that
if you are running on the stable branch of Gentoo (the default), or if you are
not using an amd64- or x86-based computer, you will need to take a few extra
steps. The good news is that if you can run Java on your
system, you should be able to run Clojure as well1.
With the proper keywording done, installing Clojure is as simple as emerge
clojure
. Note that both 1.0.0 and 1.1.0 versions of Clojure are available,
and you can install them concurrently using Gentoo’s slot mechanism. By
default, portage will install the latest version (1.1.0 slotted as 1.1), but
you can force installing version 1.0 by using slot ‘0’, i.e. emerge
clojure:0
.
The above instructions also apply for installing Clojure-contrib—simply emerge
clojure-contrib
or emerge clojure-contrib:0
.
Running Clojure
With Clojure emerged, running the REPL is as simple as typing clojure
or
clojure-1.1
, depending on which version you are using.
Including Clojure-contrib manually
Note that, by default, the Clojure commands will not include Clojure-contrib in your class path. You can do this manually on the command line by invoking Clojure using one of the following commands:
For clojure-contrib 1.1.0:
CLASSPATH=$(java-config -p clojure-contrib-1.1) clojure-1.1
For clojure-contrib 1.0.0:
CLASSPATH=$(java-config -p clojure-contrib) clojure
Including Clojure-contrib automatically
The way I prefer to run Clojure is to have the launcher script automatically
include Clojure-contrib. This can be done by customizing the launcher’s class
path by adding files to the .gentoo/java-config-2/launcher.d
directory under
your home directory2.
For version 1.1.0:
% echo 'gjl_package="clojure-contrib-1.1"' > .gentoo/java-config-2/launcher.d/clojure-1.1
For version 1.0.0:
% echo 'gjl_package="clojure-contrib"' > .gentoo/java-config-2/launcher.d/clojure
Having accomplished the above, Clojure-contrib should now be available from the launcher. For example, you could try:
% clojure-1.1
Clojure 1.1.0
user=> (use 'clojure.contrib.str-utils)
nil
user=>
Final Thoughts
This is merely the first step towards getting better Clojure support in Gentoo. Some of the next few things I am considering doing include:
- Add ebuilds for editor integration with Clojure. There is a VimClojure ebuild in java-experimental that I will soon be moving to java-overlay. Although I don’t use other editors, I think that Emacs integration would be good, too.
- Add some sort of eselect-based method to automate much of the above. I
envision a script that will manage it so that typing
clj
will launch the appropriate version of Clojure and include Clojure-contrib if desired. - Package more Clojure applications and libraries.
I am working towards become a full-fledged Gentoo Developer. Once I get there, I will have a better opportunity to help get Clojure-related packages into the main tree and help make Gentoo a very Clojure-friendly Linux distribution.
In the meantime, I appreciate any user feedback. You can find me as ‘sattvik’ on Freenode on #gentoo-java and #clojure. Of course, you can also leave comments on this site.
Footnotes
- If you do get Clojure working on non x86 or amd64 system, please make a note of it in the bugs for Clojure and Clojure-contrib.
- Alternatively, you can add these files to
/etc/java-config-2/launcher.d/
to have the effect system-wide.
TrackBacks
No trackbacks, yet.
Trackbacks are closed for this story.
Comments
-
On Wednesday, 21 Apr 2010 12:31, jonas wrote the following:
Thanks for your work so far. One additional thing that I would like to see are vcs ebuilds for clojure and clojure-contrib. I tried creating these myself but -contrib requires maven and the java-maven-2 ebuild pulls in ~120 packages and there are unresolved dependecies... Guess I will stick with 1.1 for now but once 1.2 comes out this has to be resolved anyhow, so why not start now?
-
On Friday, 23 Apr 2010 08:01, Daniel Solano Gómez wrote the following:
I will look into creating VCS ebuilds for Clojure. I think the best way to handle clojure-contrib is create an Ant build.xml ahead of time, as the actual build process itself does not require much in the way of Maven plug-ins.
Comments are closed for this story.