Continuous Integration (CI): Difference between revisions

From NixOS Wiki
imported>Mic92
add buildkite + install-nix-action
imported>Mic92
fix link
Line 26: Line 26:
=== Build kite ===  
=== Build kite ===  


NixOS comes with a module to run [[https://buildkite.com build-kite]] agents:
NixOS comes with a module to run [https://buildkite.com build-kite] agents:


<syntaxHighlight lang=nix>
<syntaxHighlight lang=nix>

Revision as of 22:10, 25 July 2020

Nix nicely integrates into your CI.

TODO: some general tips & tricks

nix-build, without downloading the result if already built

nix-build will always ensure the built store path is put in the local store, be it by building or by downloading from a substituter. On CI, we often only want to check whether we can build the derivation, without using or running the output.

This can be achieved by using `--dry-run` to check whether the result would be fetched, and only building it it has to be built.

nix-build-if-changed.py implements this in a relatively straightforward (but naïve) Python script.

nix-build-uncached implements it in a slightly more elaborate manner, and is available on nixpkgs (as the nix-build-uncached package).

Instructions for specific CI Providers

Travis CI

See Nix_on_Travis article

Github actions

See install-nix-action to install nix in Linux/macOS actions. There is also one action to setup cachix, a hosted binary cache.

Build kite

NixOS comes with a module to run build-kite agents:

{
  services.buildkite-agents.builder = {
    enable = true;
    # store a token provided in the  buildkite webinterface in the `Agents` tab under `Agents token`
    tokenPath = "/path/to/token";
    privateSshKeyPath = "/path/to/ssh/key;
  };
}

Further NixOS options