|
1 | 1 | # Buildbot-nix
|
2 | 2 |
|
3 |
| -A nixos module to make [buildbot](https://www.buildbot.net/) a proper Nix-CI. |
| 3 | +Buildbot-nix is a NixOS module designed to integrate |
| 4 | +[Buildbot](https://www.buildbot.net/), a continuous integration (CI) framework, |
| 5 | +into the Nix ecosystem. This module is under active development, and while it's |
| 6 | +generally stable and widely used, please be aware that some APIs may change over |
| 7 | +time. |
4 | 8 |
|
5 |
| -For an example checkout the [example](./examples/default.nix) and the module |
6 |
| -descriptions for [master](./nix/master.nix) and [worker](./nix/worker.nix). |
| 9 | +## Getting Started with Buildbot Setup |
7 | 10 |
|
8 |
| -This project is still in early stage and many APIs might change over time. |
| 11 | +To set up Buildbot using Buildbot-nix, you can start by exploring the provided |
| 12 | +examples: |
9 | 13 |
|
10 |
| -## Github |
| 14 | +- Check out the basic setup in [example](./examples/default.nix). |
| 15 | +- Learn about configuring the Buildbot master in |
| 16 | + [master module](./nix/master.nix). |
| 17 | +- Understand how to set up a Buildbot worker in |
| 18 | + [worker module](./nix/worker.nix). |
11 | 19 |
|
12 |
| -We currently primarly support Github as a platform but we are also looking into |
13 |
| -supporting other CIs such as gitea. |
| 20 | +Additionally, you can find real-world examples at the end of this document. |
14 | 21 |
|
15 |
| -Buildbot requires a GitHub app, to allow login for GitHub users to its |
16 |
| -dashboard. After installing the app, create oauth credentials and set them in |
17 |
| -the buildbot-nix nixos module. |
| 22 | +Buildbot masters and workers can be deployed either on the same machine or on |
| 23 | +separate machines. To support multiple architectures, configure them as |
| 24 | +[nix remote builders](https://nixos.org/manual/nix/stable/advanced-topics/distributed-builds). |
| 25 | +For a practical NixOS example, see |
| 26 | +[this remote builder configuration](https://github.com/Mic92/dotfiles/blob/main/nixos/eve/modules/remote-builder.nix). |
18 | 27 |
|
19 |
| -Furthermore buildbot requires a github token with the following permissions: |
| 28 | +## Using Buildbot in Your Project |
20 | 29 |
|
21 |
| -- `admin:repo_hook`, `repo` |
| 30 | +Buildbot-nix automatically triggers builds for your project under these |
| 31 | +conditions: |
22 | 32 |
|
23 |
| -For github organisations it's recommend to create an additional GitHub user for |
24 |
| -that. |
| 33 | +- When a pull request is opened. |
| 34 | +- When a commit is pushed to the default git branch. |
25 | 35 |
|
26 |
| -## Real-worlds deployments |
| 36 | +It does this by evaluating the `.#checks` attribute of your project's flake in |
| 37 | +parallel. Each attribute found results in a separate build step. You can test |
| 38 | +these builds locally using `nix flake check -L` or |
| 39 | +[nix-fast-build](https://github.com/Mic92/nix-fast-build). |
27 | 40 |
|
28 |
| -- [Nix-community infra](https://github.com/nix-community/infra/tree/master/modules/nixos) |
29 |
| -- [Mic92's dotfiles](https://github.com/Mic92/dotfiles/blob/main/nixos/eve/modules/buildbot.nix) |
30 |
| -- [Technical University Munich](https://github.com/TUM-DSE/doctor-cluster-config/tree/master/modules/buildbot) |
| 41 | +If you need to build other parts of your flake, such as packages or NixOS |
| 42 | +machines, you should re-export these into the `.#checks` output. Here are two |
| 43 | +examples to guide you: |
| 44 | + |
| 45 | +- Using |
| 46 | + [flake-parts](https://github.com/Mic92/dotfiles/blob/10890601a02f843b49fe686d7bc19cb66a04e3d7/flake.nix#L139). |
| 47 | +- A |
| 48 | + [plain flake example](https://github.com/nix-community/nixos-images/blob/56b52791312edeade1e6bd853ce56c778f363d50/flake.nix#L53). |
| 49 | + |
| 50 | +### Integration with GitHub |
| 51 | + |
| 52 | +Buildbot-nix primarily supports GitHub, with plans to extend support to other |
| 53 | +platforms like Gitea. |
| 54 | + |
| 55 | +To integrate with GitHub: |
| 56 | + |
| 57 | +1. **GitHub App**: Set up a GitHub app for Buildbot to enable GitHub user |
| 58 | + authentication on the Buildbot dashboard. |
| 59 | +2. **OAuth Credentials**: After installing the app, generate OAuth credentials |
| 60 | + and configure them in the buildbot-nix NixOS module. |
| 61 | +3. **GitHub Token**: Obtain a GitHub token with `admin:repo_hook` and `repo` |
| 62 | + permissions. For GitHub organizations, it's advisable to create a separate |
| 63 | + GitHub user for managing repository webhooks. |
| 64 | + |
| 65 | +### Real-World Deployments |
| 66 | + |
| 67 | +See Buildbot-nix in action in these deployments: |
| 68 | + |
| 69 | +- **Nix-community infra**: |
| 70 | + [Configuration](https://github.com/nix-community/infra/tree/master/modules/nixos) |
| 71 | + | [Instance](https://buildbot.nix-community.org/) |
| 72 | +- **Mic92's dotfiles**: |
| 73 | + [Configuration](https://github.com/Mic92/dotfiles/blob/main/nixos/eve/modules/buildbot.nix) |
| 74 | + | [Instance](https://buildbot.thalheim.io/) |
| 75 | +- **Technical University Munich**: |
| 76 | + [Configuration](https://github.com/TUM-DSE/doctor-cluster-config/tree/master/modules/buildbot) |
| 77 | + | [Instance](https://buildbot.dse.in.tum.de/) |
| 78 | +- **Numtide**: [Instance](https://buildbot.numtide.com) |
0 commit comments