Nix on Travis: Difference between revisions
imported>Vbgl on caching |
imported>Erikarvstedt mNo edit summary |
||
| (6 intermediate revisions by 4 users not shown) | |||
| Line 1: | Line 1: | ||
Travis-CI provides a <code>language: nix</code> setting (to put in a ''.travis.yml'' file) to run continuous integration scripts on a machine with Nix installed. | Travis-CI provides a <code>language: nix</code> setting (to put in a ''.travis.yml'' file) to run continuous integration scripts on a machine with Nix installed. | ||
See [https://docs.travis-ci.com/user/languages/nix Travis-CI documentation for Nix]. | See [https://docs.travis-ci.com/user/languages/nix Travis-CI documentation for Nix], [https://github.com/travis-ci/travis-build/blob/master/lib/travis/build/script/nix.rb Travis source code for Nix]. | ||
== Caching dependencies == | == Caching dependencies == | ||
| Line 17: | Line 17: | ||
<pre>before_install: | <pre>before_install: | ||
- sudo mkdir -p /etc/nix | - sudo mkdir -p /etc/nix | ||
- echo " | - echo "substituters = https://cache.nixos.org/ file://$HOME/nix.store" | sudo tee -a /etc/nix/nix.conf > /dev/null | ||
- echo 'require-sigs = false' | sudo tee -a /etc/nix/nix.conf > /dev/null</pre> | - echo 'require-sigs = false' | sudo tee -a /etc/nix/nix.conf > /dev/null</pre> | ||
| Line 33: | Line 33: | ||
NB: in this setting, the cache only grows. It might be manually deleted when it becomes too bloated but smarter eviction strategies can be implemented too! | NB: in this setting, the cache only grows. It might be manually deleted when it becomes too bloated but smarter eviction strategies can be implemented too! | ||
== Enable sandboxed builds == | |||
At the moment travis does not have a sandbox enabled by default. | |||
This can lead to non-trivial to reproduce errors, | |||
when files from the travis image interfere with the build. | |||
Enabling however is straight-forward by using the following little snippet: | |||
<syntaxHighlight lang=nix> | |||
before_script: | |||
- sudo mkdir -p /etc/nix && echo 'sandbox = true' | sudo tee /etc/nix/nix.conf | |||
</syntaxHighlight> | |||