Continuous Integration (CI): Difference between revisions

From NixOS Wiki
imported>Mic92
imported>Mic92
No edit summary
Line 32: Line 32:
There is no official NixOS module however both drone and drone-cli are packaged in nixpkgs.
There is no official NixOS module however both drone and drone-cli are packaged in nixpkgs.


Mic92 has the following [https://github.com/Mic92/dotfiles/blob/master/nixos/eve/modules/drone.nix custom module] in his repository. An example public project can be found in [https://github.com/Mic92/sops-nix/blob/master/.drone.yml sops-nix] and this project for an example using flakes [Mic92's dotfiles](https://github.com/Mic92/dotfiles/blob/master/.drone.yml).
Mic92 has the following [https://github.com/Mic92/dotfiles/blob/master/nixos/eve/modules/drone.nix custom module] in his repository. An example public project can be found in [https://github.com/Mic92/sops-nix/blob/master/.drone.yml sops-nix] and this project for an example using flakes [https://github.com/Mic92/dotfiles/blob/master/.drone.yml Mic92's dotfiles].


=== Jenkins ===
=== Jenkins ===


[https://github.com/mrVanDalo mrVanDalo] has a [https://git.ingolf-wagner.de/palo/nixos-config/src/master/library/jenkins.nix library] to declare jenkins in his repository. It can be used as shown [https://git.ingolf-wagner.de/palo/nixos-config/src/master/configs/workhorse/jenkins.nix here]
[https://github.com/mrVanDalo mrVanDalo] has a [https://git.ingolf-wagner.de/palo/nixos-config/src/master/library/jenkins.nix library] to declare jenkins in his repository. It can be used as shown [https://git.ingolf-wagner.de/palo/nixos-config/src/master/configs/workhorse/jenkins.nix here]

Revision as of 21:19, 3 August 2020

Nix nicely integrates into your CI.

TODO: some general tips & tricks

Avoid downloading already built results

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

See the Buildkite article

Drone

There is no official NixOS module however both drone and drone-cli are packaged in nixpkgs.

Mic92 has the following custom module in his repository. An example public project can be found in sops-nix and this project for an example using flakes Mic92's dotfiles.

Jenkins

mrVanDalo has a library to declare jenkins in his repository. It can be used as shown here