Skip to content

Commit

Permalink
Add logging to ci build script
Browse files Browse the repository at this point in the history
  • Loading branch information
ooesili committed Mar 21, 2021
1 parent 2e50045 commit e9ca7fc
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions ci/build-dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,36 @@ CACHE_CLOSURE_FILE=/tmp/build-inputs.closure

main() {
cache_restore
cache_store "$(nix-build -A inputDerivation --no-link)"
cache_store "$(build_dependencies)"
}

cache_restore() {
echo '===> restoring from cache'
cache restore "nix-$SEMAPHORE_GIT_BRANCH,nix-master,nix-store"

if [[ -f $CACHE_CLOSURE_FILE ]]; then
echo "===> importing cached closure into the nix store"
nix-store --import < $CACHE_CLOSURE_FILE
else
echo "===> cache did not contain a file called $CACHE_CLOSURE_FILE"
fi
}

build_dependencies() {
echo '===> building dependencies'
nix-build -A inputDerivation --no-link
}

cache_store() {
local deps_store_path=$1

local cache_key
cache_key="nix-$SEMAPHORE_GIT_BRANCH-$(output_hash "$deps_store_path")"

if ! cache has_key "$cache_key"; then
if cache has_key "$cache_key"; then
echo "===> cache already contains key $cache_key, nothing to do"
else
echo "===> caching store closure"
nix-store --export "$(nix-store -qR "$deps_store_path")" > $CACHE_CLOSURE_FILE
cache store "$cache_key" $CACHE_CLOSURE_FILE
fi
Expand Down

0 comments on commit e9ca7fc

Please sign in to comment.