Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ stages:
jobs:
include:

- name: "Bazel"
script:
- ./scripts/ci-jobs.sh bazel

- name: "Test"
script:
- ./scripts/ci-jobs.sh test
Expand Down
20 changes: 5 additions & 15 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,13 @@ stdenv.mkDerivation rec {
name = "env";

src = builtins.filterSource (path: type: false) ./.;

bazel = (import (fetchFromGitHub {
owner = "andyscott";
repo = "bazel-nix";
rev = "d03cebdba5aefdccad70608ec348fdd1ca0c1ed1";
sha256 = "08znczxmm4ijlw3lfcz8xw3f1368nn56i5ka453gygslj6qfg1g3";
})) {
version = "0.14.1";
};

buildInputs = [
git sbt nodejs bazel
sbt bazel nodejs git
];

installPhase = ''
mkdir -p $out
ln -s $bazel/bin/bazel $out/bazel
'';
shellHook =
''
export IS_IN_NIX=true
'';
}

3 changes: 3 additions & 0 deletions scripts/ci-jobs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
set -euxo pipefail

case "$1" in
"bazel")
bazel build ...
;;
"test")
sbt ';+clean;test'
;;
Expand Down
39 changes: 9 additions & 30 deletions tools/bazel
Original file line number Diff line number Diff line change
@@ -1,34 +1,13 @@
#!/bin/bash

set -eo pipefail

if [ ! -z "$BAZEL_IN_NIX" ]; then
exec $BAZEL_REAL "$@"
fi

function mtime_darwin() {
stat -f "%m" $1
}
function mtime_gnu() {
stat -c "%Y" $1
}

if mtime_darwin "$BAZEL_REAL" >/dev/null 2>&1; then
mtime=mtime_darwin
if [ -z "$IS_IN_NIX" ]; then
echo ""
echo "You're running Bazel from outside of nix-shell!"
echo "This will incur a slight overhead on each bazel invocation"
echo "Consider entering a nix-shell if you'd like to avoid this overhead"
echo ""

eval nix-shell --command \"bazel $@\"
else
mtime=mtime_gnu
$BAZEL_REAL "$@"
fi

t0=$($mtime ./result) || t0=0

for file in *.nix; do
t=$($mtime $file)
if [[ $t -gt $t0 ]]; then
echo 'The Nix environment is out of date! Rebuilding now...'
nix-build
echo 'Done!'
break
fi
done

BAZEL_IN_NIX=true exec ./result/bazel "$@"