Installation
This chapter explains how to install Hydra on your own build farm server.
Prerequisites
To install and use Hydra you need to have installed the following dependencies:
Nixeither PostgreSQL or SQLitemany Perl packages, notably Catalyst,
EmailSender, and NixPerl (see the Hydra
expression in Nixpkgs for the complete
list).
At the moment, Hydra runs only on GNU/Linux
(i686-linux and
x86_64_linux).
For small projects, Hydra can be run on any reasonably
modern machine. For individual projects you can even run
Hydra on a laptop. However, the charm of a buildfarm server
is usually that it operates without disturbing the
developer's working environment and can serve releases over
the internet. In conjunction you should typically have your
source code administered in a version management system,
such as subversion. Therefore, you will probably want to
install a server that is connected to the internet. To scale
up to large and/or many projects, you will need at least a
considerable amount of diskspace to store builds. Since
Hydra can schedule multiple simultaneous build jobs, it can
be useful to have a multi-core machine, and/or attach
multiple build machines in a network to the central Hydra
server.
Of course we think it is a good idea to use the NixOS GNU/Linux
distribution for your buildfarm server. But this is not a
requirement. The Nix software deployment system can be
installed on any GNU/Linux distribution in parallel to the
regular package management system. Thus, you can use Hydra
on a Debian, Fedora, SuSE, or Ubuntu system.
Getting Nix
If your server runs NixOS you are all set to continue with
installation of Hydra. Otherwise you first need to install
Nix. The latest stable version can be found one the Nix web
site, along with a manual, which includes installation
instructions.
Installation
Hydra can be installed using Nixpkgs:
nix-env -Ai hydra -f /path/to/nixpkgs
This makes the tools available in your Nix user environment,
$HOME/.nix-profile by default.
Alternatively, the latest development snapshot can be
installed by visiting the URL
http://hydra.nixos.org/view/hydra/unstable
and use the one-click install available at one of the build pages. You can also
install Hydra through the channel by performing the following commands:
nix-channel --add http://hydra.nixos.org/jobset/hydra/trunk/channel/latest
nix-channel --update
nix-env -i hydra
Command completion should reveal a number of command-line tools from Hydra:
hydra_build.pl hydra_eval_jobs hydra_server.pl
hydra_control.sh hydra_evaluator.pl hydra_update_gc_roots.pl
hydra_create.pl hydra_queue_runner.pl Creating the database
Hydra stores its results in a database, which can be a
PostgreSQL or SQLite database. The latter is easier to
setup, but the former scales better.
To setup a PostgreSQL
database with hydra as database name
and user name, issue the following commands:
createdb hydra
echo "CREATE USER hydra WITH PASSWORD '<your-password>' ;" | psql hydra
cat $prefix/share/hydra/sql/hydra-postgresql.sql | psql hydra
echo "GRANT ALL ON DATABASE hydra TO hydra;" | psql hydra
Note that $prefix is the location of
Hydra in the nix store.
For SQLite, the following command is all it takes to
create the database:
cat $prefix/share/hydra/sql/hydra-sqlite.sql | sqlite3 /path/to/hydra.sqlite
To add a user root with admin privileges, execute:
echo "INSERT INTO Users(userName, emailAddress, password) VALUES ('root', 'some@email.adress.com', '$(echo -n foobar | sha1sum | cut -c1-40)');" | psql hydra
echo "INSERT INTO UserRoles(userName, role) values('root', 'admin');" | psql hydra
For SQLite the same commands can be used, with
psql hydra replaced by
sqlite3 /path/to/hydra.sqlite.
Hydra uses an environment variable to know which database
should be used, and a variable which point to a location
that holds some state. To set these variables for a
PostgreSQL database, add the following to the
.profile of the user running the
Hydra services.
export HYDRA_DBI="dbi:Pg:dbname=hydra;host=localhost;"
export HYDRA_DATA=/var/lib/hydra
Make sure that the HYDRA_DATA
directory exists and is writable for the user which will
run the Hydra services. For a SQLite database, the
HYDRA_DBI should be set to something
like dbi:SQLite:/path/to/hydra.sqliteGetting Started
To start the Hydra web server, execute:
hydra_server.pl
When the server is started, you can browse to
http://localhost:3000/ to start configuring
your Hydra instance.
The hydra_server.pl command launches the
web server. There are two other processes that come into
play:
The evaluator is responsible for
peridically evaluating job sets, checking out their
dependencies off their version control systems (VCS),
and queueing new builds if the result of the evaluation
changed. It is launched by the
hydra_evaluator.pl command.
The queue runner launches builds
(using Nix) as they are queued by the evaluator,
scheduling them onto the configured Nix hosts. It is
launched using the
hydra_queue_runner.pl command.
All three processes must be running for Hydra to be fully
functional, though it's possible to temporarily stop any one
of them for maintenance purposes, for instance.