2014-09-21 13:09:35 +02:00
|
|
|
#! /usr/bin/env bash
|
|
|
|
set -e
|
|
|
|
|
2014-10-14 14:31:43 +02:00
|
|
|
export NIX_CURL_FLAGS=-sS
|
|
|
|
|
2014-10-15 11:03:30 +02:00
|
|
|
if [[ $1 == nix ]]; then
|
2014-10-15 18:50:28 +02:00
|
|
|
echo "=== Installing Nix..."
|
2014-10-15 11:03:30 +02:00
|
|
|
# Install Nix
|
2014-10-15 18:45:13 +02:00
|
|
|
bash <(curl -sS https://nixos.org/nix/install)
|
2014-10-15 11:03:30 +02:00
|
|
|
source $HOME/.nix-profile/etc/profile.d/nix.sh
|
2014-09-21 13:09:35 +02:00
|
|
|
|
2014-10-15 11:03:30 +02:00
|
|
|
# Make sure we can use hydra's binary cache
|
|
|
|
sudo mkdir /etc/nix
|
2016-02-28 20:17:52 +01:00
|
|
|
sudo sh -c 'echo "build-max-jobs = 4" > /etc/nix/nix.conf'
|
2014-09-21 13:09:35 +02:00
|
|
|
|
2014-10-15 11:03:30 +02:00
|
|
|
# Verify evaluation
|
2014-10-15 18:50:28 +02:00
|
|
|
echo "=== Verifying that nixpkgs evaluates..."
|
|
|
|
nix-env -f. -qa --json >/dev/null
|
2014-10-15 11:23:34 +02:00
|
|
|
elif [[ $1 == nox ]]; then
|
2016-05-31 13:59:24 +02:00
|
|
|
source $HOME/.nix-profile/etc/profile.d/nix.sh
|
2014-10-15 18:50:28 +02:00
|
|
|
echo "=== Installing nox..."
|
2016-06-01 16:31:14 +02:00
|
|
|
nix-build -A nox '<nixpkgs>' --show-trace
|
2014-10-15 11:03:30 +02:00
|
|
|
elif [[ $1 == build ]]; then
|
2014-10-15 11:52:23 +02:00
|
|
|
source $HOME/.nix-profile/etc/profile.d/nix.sh
|
|
|
|
|
2016-05-31 12:34:59 +02:00
|
|
|
if [[ $TRAVIS_OS_NAME == "osx" ]]; then
|
2016-05-31 19:58:59 +02:00
|
|
|
echo "Skipping NixOS things on darwin"
|
2016-05-31 12:34:59 +02:00
|
|
|
else
|
2016-06-16 12:18:16 +02:00
|
|
|
# Nix builds in /tmp and we need exec support
|
|
|
|
sudo mount -o remount,exec /run
|
|
|
|
sudo mount -o remount,exec /run/user
|
|
|
|
sudo mount
|
|
|
|
|
2016-05-31 19:58:59 +02:00
|
|
|
echo "=== Checking NixOS options"
|
2016-06-01 16:31:14 +02:00
|
|
|
nix-build nixos/release.nix -A options --show-trace
|
2016-05-31 19:58:59 +02:00
|
|
|
|
|
|
|
echo "=== Checking tarball creation"
|
2016-06-01 16:31:14 +02:00
|
|
|
nix-build pkgs/top-level/release.nix -A tarball --show-trace
|
2016-05-31 12:34:59 +02:00
|
|
|
fi
|
2016-02-25 16:59:35 +01:00
|
|
|
|
2014-10-15 11:03:30 +02:00
|
|
|
if [[ $TRAVIS_PULL_REQUEST == false ]]; then
|
2015-01-01 22:16:31 +01:00
|
|
|
echo "=== Not a pull request"
|
2014-10-15 11:03:30 +02:00
|
|
|
else
|
2014-10-15 18:50:28 +02:00
|
|
|
echo "=== Checking PR"
|
2015-06-20 20:15:39 +02:00
|
|
|
|
2016-05-31 13:59:24 +02:00
|
|
|
if ! nix-shell -p nox --run "nox-review pr ${TRAVIS_PULL_REQUEST}"; then
|
2015-06-20 20:15:39 +02:00
|
|
|
if sudo dmesg | egrep 'Out of memory|Killed process' > /tmp/oom-log; then
|
|
|
|
echo "=== The build failed due to running out of memory:"
|
|
|
|
cat /tmp/oom-log
|
|
|
|
echo "=== Please disregard the result of this Travis build."
|
|
|
|
fi
|
|
|
|
exit 1
|
|
|
|
fi
|
2014-10-15 11:03:30 +02:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "$0: Unknown option $1" >&2
|
|
|
|
false
|
2014-09-21 13:09:35 +02:00
|
|
|
fi
|