scylla

Nix Flavoured Continuous Integration

Scylla is a simple CI server that solves one thing: Evaluate Nix derivations and inform you and GitHub about the results.

Scylla is implemented in Go, and needs nothing but Nix for building, logging, and caching.

I try to keep the moving parts as reliable as possible, since at the end of the day, all we care about is that it works.

What Scylla Can Do For You

  • Create binaries
  • Run tests
  • Populate your Nix cache
  • Update your GitHub PR status
  • Serve logs of your project builds

Getting Started

GitHub

  1. Get an OAuth token

    Navigate to https://github.com/settings/tokens and generate a new OAuth token. It only needs the repo:status permission.

  2. Add the webhook

    Go to https://github.com/$owner/$repo/settings/hooks (substitute your owner/repo in the URL).

    Add a webhook that points to your server, like https://$host/github-webhook (substitute host here to the location of your server, you can also use something like ngrok for trying it out).
    These settings are required:

    • Content type: application/json
    • Secret: (anything you want)
    • Enable at least the pull request event. The rest will at the momemt be simply ignored.
  3. Configure the server

    Configuration is done via Environment variables (although flags also work). You need to set the following:

    • GITHUB_TOKEN: The token you created in the first step
    • GITHUB_USER: The token you created in the first step

GitLab

This is still work in progress, while in theory the hook should work, the status updates aren't reflected anywhere on the Gitlab page. Maybe someone actually using Gitlab can investigate that.

The ci.nix

Add a ci.nix file to the project you want to use it with.

The following is just an example of the structure. It's strongly recommended that you use a pinned version of nixpkgs so both Scylla and you are actually building identical things.

{ nixpkgs ? import (fetchGit {
  url = https://github.com/NixOS/nixpkgs;
  ref = "24429d66a3fa40ca98b50cad0c9153e80f56c4a2";
}) {} }: {
  app-binary = callPackage ./. {};
  app-tests = recurseIntoAttrs {
    callPackage ./. { slowTests = true; };
    callPackage ./. { fastTests = true; };
  }
}

All atributes in the returned attrset will be evaluated, in this case app-binary and app-tests. What Scylla actually does is to simply call nix-build on your ci.nix and store the results.

So you can make sure the ci.nix is working by doing that yourself first locally.

The recurseIntoAttrs function can be used to also build nested attrsets. Otherwise only functions in the top-level will be built.

Development

Building the server

nix build -f ci.nix scylla

Running the server

./result/bin/scylla
Repository

scylla

Owner
Statistic
  • 0
  • 0
  • 0
  • 0
  • 7
  • almost 6 years ago
  • July 31, 2018
License

MIT License

Links
Synced at

Sun, 05 May 2024 18:08:23 GMT

Languages