2021-04-05 15:30:41 +00:00
|
|
|
# Hacking
|
2021-02-23 23:25:56 +00:00
|
|
|
|
|
|
|
This section provides some notes on how to hack on Hydra. To get the
|
|
|
|
latest version of Hydra from GitHub:
|
|
|
|
|
2021-04-05 17:06:45 +00:00
|
|
|
```console
|
2021-04-05 16:07:00 +00:00
|
|
|
$ git clone git://github.com/NixOS/hydra.git
|
|
|
|
$ cd hydra
|
|
|
|
```
|
2021-02-23 23:25:56 +00:00
|
|
|
|
2021-04-05 16:07:19 +00:00
|
|
|
To enter a shell in which all environment variables (such as `PERL5LIB`)
|
2021-04-05 16:08:06 +00:00
|
|
|
and dependencies can be found:
|
2021-02-23 23:25:56 +00:00
|
|
|
|
2021-04-05 16:07:00 +00:00
|
|
|
```console
|
|
|
|
$ nix-shell
|
|
|
|
```
|
2021-02-23 23:25:56 +00:00
|
|
|
|
|
|
|
To build Hydra, you should then do:
|
|
|
|
|
2021-04-05 16:07:00 +00:00
|
|
|
```console
|
2024-01-26 16:28:07 +00:00
|
|
|
[nix-shell]$ autoreconfPhase
|
2021-04-05 16:07:00 +00:00
|
|
|
[nix-shell]$ configurePhase
|
|
|
|
[nix-shell]$ make
|
|
|
|
```
|
2021-02-23 23:25:56 +00:00
|
|
|
|
2021-04-05 15:30:41 +00:00
|
|
|
You start a local database, the webserver, and other components with
|
|
|
|
foreman:
|
|
|
|
|
2021-04-05 16:07:00 +00:00
|
|
|
```console
|
|
|
|
$ foreman start
|
|
|
|
```
|
2021-04-05 15:30:41 +00:00
|
|
|
|
|
|
|
You can run just the Hydra web server in your source tree as follows:
|
2021-02-23 23:25:56 +00:00
|
|
|
|
2021-04-05 16:07:00 +00:00
|
|
|
```console
|
|
|
|
$ ./src/script/hydra-server
|
|
|
|
```
|
2021-03-05 08:01:49 +00:00
|
|
|
|
|
|
|
You can run Hydra's test suite with the following:
|
|
|
|
|
2021-04-05 16:07:00 +00:00
|
|
|
```console
|
|
|
|
[nix-shell]$ make check
|
|
|
|
[nix-shell]$ # to run as many tests as you have cores:
|
|
|
|
[nix-shell]$ make check YATH_JOB_COUNT=$NIX_BUILD_CORES
|
|
|
|
[nix-shell]$ # or run yath directly:
|
|
|
|
[nix-shell]$ yath test
|
|
|
|
[nix-shell]$ # to run as many tests as you have cores:
|
|
|
|
[nix-shell]$ yath test -j $NIX_BUILD_CORES
|
|
|
|
```
|
2021-03-05 08:01:49 +00:00
|
|
|
|
|
|
|
When using `yath` instead of `make check`, ensure you have run `make`
|
|
|
|
in the root of the repository at least once.
|
|
|
|
|
|
|
|
**Warning**: Currently, the tests can fail
|
|
|
|
if run with high parallelism [due to an issue in
|
|
|
|
`Test::PostgreSQL`](https://github.com/TJC/Test-postgresql/issues/40)
|
|
|
|
causing database ports to collide.
|
2021-04-05 15:30:41 +00:00
|
|
|
|
2021-04-05 15:39:49 +00:00
|
|
|
## Working on the Manual
|
|
|
|
|
|
|
|
By default, `foreman start` runs mdbook in "watch" mode. mdbook listens
|
2021-04-05 16:07:30 +00:00
|
|
|
at [http://localhost:63332/](http://localhost:63332/), and
|
2021-04-05 15:39:49 +00:00
|
|
|
will reload the page every time you save.
|
|
|
|
|
2021-04-05 15:30:41 +00:00
|
|
|
## Building
|
|
|
|
|
|
|
|
To build Hydra and its dependencies:
|
|
|
|
|
2021-04-05 16:07:00 +00:00
|
|
|
```console
|
|
|
|
$ nix-build release.nix -A build.x86_64-linux
|
|
|
|
```
|
2021-04-05 17:06:45 +00:00
|
|
|
|
|
|
|
## Development Tasks
|
|
|
|
|
|
|
|
### Connecting to the database
|
|
|
|
|
2021-11-02 13:39:58 +00:00
|
|
|
Assuming you're running the default configuration with `foreman start`,
|
2021-04-05 17:06:45 +00:00
|
|
|
open an interactive session with Postgres via:
|
|
|
|
|
|
|
|
```console
|
|
|
|
$ psql --host localhost --port 64444 hydra
|
|
|
|
```
|
|
|
|
|
|
|
|
### Runinng the builder locally
|
|
|
|
|
|
|
|
For `hydra-queue-runner` to successfully build locally, your
|
|
|
|
development user will need to be "trusted" by your Nix store.
|
|
|
|
|
|
|
|
Add yourself to the `trusted_users` option of `/etc/nix/nix.conf`.
|
|
|
|
|
|
|
|
On NixOS:
|
|
|
|
|
|
|
|
```nix
|
|
|
|
{
|
2022-09-27 20:44:27 +00:00
|
|
|
nix.settings.trusted-users = [ "YOURUSER" ];
|
2021-04-05 17:06:45 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
Off NixOS, change `/etc/nix/nix.conf`:
|
|
|
|
|
|
|
|
```conf
|
|
|
|
trusted-users = root YOURUSERNAME
|
|
|
|
```
|