2020-10-29 08:11:17 +03:00
|
|
|
language: nix
|
2020-12-08 20:39:18 +03:00
|
|
|
|
|
|
|
env:
|
|
|
|
global:
|
|
|
|
- CACHIX_CACHE=noredink-ui
|
2018-03-28 05:16:50 +03:00
|
|
|
|
2018-03-27 17:13:23 +03:00
|
|
|
cache:
|
|
|
|
directories:
|
2018-03-28 06:23:32 +03:00
|
|
|
- node_modules
|
2020-09-18 13:55:55 +03:00
|
|
|
- ~/.elm
|
2018-03-27 17:13:23 +03:00
|
|
|
|
|
|
|
install:
|
2020-12-10 19:23:53 +03:00
|
|
|
# This setup script comes from the cachix docs[1], but we annotate it here so
|
|
|
|
# it's easier to maintain.
|
|
|
|
#
|
|
|
|
# [1]: https://docs.cachix.org/continuous-integration-setup/travis-ci.html
|
|
|
|
|
|
|
|
# First, we need to tell Nix that the current user is trusted to make changes to
|
|
|
|
# the system configuration, so that we can do exactly that in the next step.
|
2020-12-08 20:39:18 +03:00
|
|
|
- echo "trusted-users = $USER" | sudo tee -a /etc/nix/nix.conf
|
|
|
|
- sudo systemctl restart nix-daemon
|
2020-12-10 19:23:53 +03:00
|
|
|
|
|
|
|
# Next, we need to tell Nix to use our cache to avoid building fresh every time.
|
|
|
|
# Under the covers, this means trusting the signing key and adding the
|
|
|
|
# our-cache-name.cachix.org as a substituter. But we don't really need to worry
|
|
|
|
# a lot about the mechanism here, since the `cachix use` statement here will
|
|
|
|
# take care of everything for us if it has the right permissions.
|
2020-12-08 20:39:18 +03:00
|
|
|
- nix-env -iA nixpkgs.cachix
|
|
|
|
- cachix use $CACHIX_CACHE
|
2020-12-10 19:23:53 +03:00
|
|
|
|
|
|
|
# Next, we list all the paths that Nix currently knows about so that we don't
|
|
|
|
# waste time trying to push them later.
|
2020-12-08 20:39:18 +03:00
|
|
|
- nix path-info --all > /tmp/store-path-pre-build
|
|
|
|
|
2020-12-10 19:23:53 +03:00
|
|
|
# Finally, we run `nix-shell` with a no-op command to download our real
|
|
|
|
# dependencies. This step should now take advantage of the cachix cache and
|
|
|
|
# avoid rebuilding any upstream software we depend on! (At the time of this
|
|
|
|
# writing, that measn we avoid compiling `niv` and `elm-forbid-import` on every
|
|
|
|
# run.)
|
|
|
|
#
|
|
|
|
# Note that this step is technically not necessary--running our build command in
|
|
|
|
# `nix-shell` below would also take care of this--but getting dependencies here
|
|
|
|
# lets us collapse the (huge) download list in the Travis UI.
|
|
|
|
- nix-shell --run 'true'
|
2018-03-27 17:13:23 +03:00
|
|
|
|
|
|
|
script:
|
2020-10-30 18:26:20 +03:00
|
|
|
- nix-shell --pure --run 'shake --verbose ci'
|
2020-12-08 20:39:18 +03:00
|
|
|
|
|
|
|
after_success:
|
2020-12-10 19:23:53 +03:00
|
|
|
# After we successfully build, we want to cache whatever we can. That means that
|
|
|
|
# when dependencies change, we should only build them once. The invocation below
|
|
|
|
# just gets the difference between the derivations we had before the build and
|
|
|
|
# the derivations we have now, and pushes the new ones.
|
2020-12-08 20:39:18 +03:00
|
|
|
- comm -13 <(sort /tmp/store-path-pre-build | grep -v '\.drv$') <(nix path-info --all | grep -v '\.drv$' | sort) | cachix push $CACHIX_CACHE
|