• Stars
    star
    1,128
  • Rank 41,112 (Top 0.9 %)
  • Language
    Perl
  • License
    GNU General Publi...
  • Created almost 13 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Hydra, the Nix-based continuous build system

Hydra

CI

Hydra is a Continuous Integration service for Nix based projects.

Installation And Setup

Note: The instructions provided below are intended to enable new users to get a simple, local installation up and running. They are by no means sufficient for running a production server, let alone a public instance.

Enabling The Service

Running Hydra is currently only supported on NixOS. The hydra module allows for an easy setup. The following configuration can be used for a simple setup that performs all builds on localhost (Please refer to the Options page for all available options):

{
  services.hydra = {
    enable = true;
    hydraURL = "http://localhost:3000";
    notificationSender = "hydra@localhost";
    buildMachinesFiles = [];
    useSubstitutes = true;
  };
}

Creating An Admin User

Once the Hydra service has been configured as above and activate you should already be able to access the UI interface at the specified URL. However some actions require an admin user which has to be created first:

$ su - hydra
$ hydra-create-user <USER> --full-name '<NAME>' \
    --email-address '<EMAIL>' --password-prompt --role admin

Afterwards you should be able to log by clicking on "Sign In" on the top right of the web interface using the credentials specified by hydra-create-user. Once you are logged in you can click "Admin -> Create Project" to configure your first project.

Creating A Simple Project And Jobset

In order to evaluate and build anything you need to create projects that contain jobsets. Hydra supports imperative and declarative projects and many different configurations. The steps below will guide you through the required steps to creating a minimal imperative project configuration.

Creating A Project

Log in as administrator, click "Admin" and select "Create project". Fill the form as follows:

  • Identifier: hello
  • Display name: hello
  • Description: hello project

Click "Create project".

Creating A Jobset

After creating a project you are forwarded to the project page. Click "Actions" and choose "Create jobset". Fill the form with the following values:

  • Identifier: hello
  • Nix expression: examples/hello.nix in hydra
  • Check interval: 60
  • Scheduling shares: 1

We have to add two inputs for this jobset. One for nixpkgs and one for hydra (which we are referencing in the Nix expression above):

  • Input name: nixpkgs

  • Type: Git checkout

  • Value: https://github.com/nixos/nixpkgs-channels nixos-20.03

  • Input name: hydra

  • Type: Git checkout

  • Value: https://github.com/nixos/hydra

Make sure State at the top of the page is set to "Enabled" and click on "Create jobset". This concludes the creation of a jobset that evaluates ./examples/hello.nix once a minute. Clicking "Evaluations" should list the first evaluation of the newly created jobset after a brief delay.

Building And Developing

Building Hydra

You can build Hydra via nix-build using the provided default.nix:

$ nix-build

Development Environment

You can use the provided shell.nix to get a working development environment:

$ nix-shell
$ ./bootstrap
$ configurePhase # NOTE: not ./configure
$ make

Executing Hydra During Development

When working on new features or bug fixes you need to be able to run Hydra from your working copy. This can be done using foreman:

$ nix-shell
$ # hack hack
$ make
$ foreman start

Have a look at the Procfile if you want to see how the processes are being started. In order to avoid conflicts with services that might be running on your host, hydra and postgress are started on custom ports:

  • hydra-server: 63333 with the username "alice" and the password "foobar"
  • postgresql: 64444

Note that this is only ever meant as an ad-hoc way of executing Hydra during development. Please make use of the NixOS module for actually running Hydra in production.

Checking your patches

After making your changes, verify the test suite passes and perlcritic is still happy.

Start by following the steps in Development Environment.

Then, you can run the tests and the perlcritic linter together with:

$ nix-shell
$ make check

You can run a single test with:

$ nix-shell
$ yath test ./t/foo/bar.t

And you can run just perlcritic with:

$ nix-shell
$ make perlcritic

JSON API

You can also interface with Hydra through a JSON API. The API is defined in hydra-api.yaml and you can test and explore via the swagger editor

Additional Resources

License

Hydra is licensed under GPL-3.0

Icons provided free by EmojiOne.

More Repositories

1

nixpkgs

Nix Packages collection & NixOS
Nix
13,126
star
2

nix

Nix, the purely functional package manager
C++
9,002
star
3

patchelf

A small utility to modify the dynamic linker and RPATH of ELF executables
C
2,931
star
4

nixos-hardware

A collection of NixOS modules covering hardware quirks.
Nix
1,864
star
5

nixops

NixOps is a tool for deploying to NixOS machines in a network or cloud.
Python
1,464
star
6

nix.dev

Official documentation for getting things done with Nix.
Python
1,458
star
7

nixfmt

The official (but not yet stable) formatter for Nix code
Nix
707
star
8

templates

Flake templates
Nix
455
star
9

nixos-search

Search NixOS packages and options
Elm
410
star
10

rfcs

The Nix community RFCs
396
star
11

cabal2nix

Generate Nix build instructions from a Cabal file
Haskell
336
star
12

nixos-homepage

Sources for nixos.org
Astro
299
star
13

nix-mode

An Emacs major mode for editing Nix expressions.
Emacs Lisp
294
star
14

nix-pills

Nix
278
star
15

ofborg

@ofborg tooling automation https://monitoring.ofborg.org/dashboard/db/ofborg
Rust
229
star
16

nixos-weekly

NixOS Weekly Newsletter
HTML
210
star
17

nixos-artwork

Nix related artwork
Nix
194
star
18

nix-book

Nix documentation – centralized community online learning resource for Nix
183
star
19

nixos-org-configurations

NixOS configurations for nixos.org and its servers
Nix
173
star
20

nixos

OBSOLETE (go to NixOS/nixpkgs) - NixOS, a Linux distribution based on the Nix package manager - OBSOLETE (go to NixOS/nixpkgs)
Shell
169
star
21

nixpkgs-channels

DEPRECATED! Use NixOS/nixpkgs repository instead.
Nix
168
star
22

nix-idea

Nix plugin for the IntelliJ IDEA IDE
Java
160
star
23

docker

DEPRECATED! Dockerfiles to package Nix in a minimal docker container
Dockerfile
148
star
24

bundlers

Nix
97
star
25

flake-registry

Global registry of Nix flakes
Shell
76
star
26

aarch64-build-box

Config for the Community aarch64 NixOS box [maintainer=@grahamc]
Nix
62
star
27

npm2nix

Generate nix expressions to build npm packages
CoffeeScript
57
star
28

nixops-aws

Python
53
star
29

nixops-hetzner

Python
47
star
30

nixpkgs-merge-bot

Allows package maintainers to merge in nixpkgs
Python
44
star
31

nixos-wiki-infra

This project contains the setup of https://wiki.nixos.org
Nix
43
star
32

equinix-metal-builders

iPXE image for Nix builders on Equinix Metal's Spot market.
Nix
39
star
33

nixpart

NixOS storage manager/partitioner
Python
38
star
34

amis

Home for NixOS AMI automation
Python
36
star
35

foundation

This is the home of the NixOS Foundation
33
star
36

nixos-channel-scripts

Perl
32
star
37

mvn2nix-maven-plugin

Generate project-info.json for use with nix's Maven repository generation functions
Java
31
star
38

security

Rust
30
star
39

language-nix

Data types and useful functions to represent and manipulate the Nix language. | Source has moved to https://github.com/nixos/cabal2nix
Haskell
30
star
40

hydra-provisioner

On-demand provisioning tool for Hydra
Python
29
star
41

release-wiki

19
star
42

distribution-nixpkgs

Haskell types and functions to represent, query, and manipulate the Nixpkgs distribution. | Source has moved to https://github.com/nixos/cabal2nix
Haskell
17
star
43

darwin-stubs

Text API (TAPI) files to support a pure build environment on macOS in nixpkgs.
Shell
15
star
44

mobile-nixos-website

Nix
14
star
45

reproducible.nixos.org

HTML
14
star
46

calamares-nixos-extensions

NixOS calamares [maintainer=@vlinkz]
Python
13
star
47

hackage-db

provide access to the Hackage database via Data.Map | Source has moved to https://github.com/nixos/cabal2nix
Haskell
13
star
48

snapd-nix-base

The Nix base snap for distributing Nix-built software via the Snap store.
Nix
12
star
49

rfc-steering-committee

Workflows and notes from Nix steering committee
Python
12
star
50

nixos-metrics

Rust
12
star
51

nix-eclipse

Nix Eclipse plugin
Java
12
star
52

nixos-common-styles

Common styles for NixOS related web sites.
Less
11
star
53

moderation

The home of the moderation team
11
star
54

jailbreak-cabal

Strip version restrictions from build dependencies in Cabal files.
Haskell
10
star
55

nixops-dashboard

NixOps Dashboard
9
star
56

nixpkgs-check-by-name

Tool to check Nixpkgs' pkgs/by-name directory
Rust
9
star
57

nixos-summer

HTML
8
star
58

nixos-status

The website showing an overview status of NixOS infra and CI.
JavaScript
8
star
59

nixos-planet

XSLT
7
star
60

ofborg-viewer

Nix
6
star
61

org

Organisational documentation
Shell
6
star
62

20th-nix

20 years of Nix
HTML
5
star
63

whats-new-in-nix

Shell
5
star
64

.github

org-level github configuration
4
star
65

hydra-ant-logger

Java
4
star
66

package-list

Deprecated, use upload-nixos-package-list-to-hackage.sh instead. Generate the list of available Haskell packages for Hackage.
Haskell
3
star
67

rfc39

Implementation of NixOS RFC #39.
Nix
3
star
68

flake-regressions

Nix flake evaluation regression testing
Nix
3
star
69

rfc39-record

2
star
70

teams-collaboration

1
star
71

nix-constitutional-assembly

1
star