mirror of
https://gitlab.com/TECHNOFAB/nix-gitlab-ci.git
synced 2025-12-11 17:50:08 +01:00
48 lines
2 KiB
Bash
48 lines
2 KiB
Bash
echo -e "\\e[0Ksection_start:`date +%s`:nix_setup[collapsed=true]\\r\\e[0KSetting up Nix CI"
|
|
nix path-info --all > /tmp/nix-store-before
|
|
|
|
if [[ "$NIX_CI_CACHE_STRATEGY" == "auto" ]]; then
|
|
export NIX_CI_CACHE_STRATEGY="${NIX_CI_RUNNER_CACHE_STRATEGY:-${NIX_CI_DEFAULT_CACHE_STRATEGY:-none}}";
|
|
echo "NIX_CI_CACHE_STRATEGY was set to auto, selected '$NIX_CI_CACHE_STRATEGY' for this job"
|
|
fi
|
|
|
|
if [ -z "$NIX_CI_DISABLE_CACHE" ]; then
|
|
echo -e "\\e[0Ksection_start:`date +%s`:cache_setup[collapsed=true]\\r\\e[0KConfiguring cache ($NIX_CI_CACHE_STRATEGY)"
|
|
case "$NIX_CI_CACHE_STRATEGY" in
|
|
"runner")
|
|
export RUNNER_CACHE=''${RUNNER_CACHE:-"file://$(pwd)/.nix-cache"}
|
|
echo "Runner Cache: $RUNNER_CACHE"
|
|
export NIX_CONFIG="$NIX_CONFIG
|
|
extra-trusted-substituters = $RUNNER_CACHE?priority=10&trusted=true
|
|
extra-substituters = $RUNNER_CACHE?priority=10&trusted=true
|
|
"
|
|
;;
|
|
"attic")
|
|
echo "Attic Cache: $ATTIC_CACHE"
|
|
attic login --set-default ci "$ATTIC_SERVER" "$ATTIC_TOKEN" || true
|
|
attic use "$ATTIC_CACHE" || true
|
|
;;
|
|
"cachix")
|
|
echo "Cachix Cache: $CACHIX_CACHE"
|
|
cachix use "$CACHIX_CACHE" || true
|
|
;;
|
|
"none")
|
|
echo "Cache strategy is none, doing nothing..."
|
|
;;
|
|
*)
|
|
echo "WARNING: Invalid cache strategy set: '$NIX_CI_CACHE_STRATEGY'"
|
|
;;
|
|
esac
|
|
echo -e "\\e[0Ksection_end:`date +%s`:cache_setup\\r\\e[0K"
|
|
else
|
|
echo "Caching disabled (NIX_CI_DISABLE_CACHE), skipping cache configuration..."
|
|
fi
|
|
|
|
# load the job's deps only if the name was passed
|
|
if [[ ! -z $1 ]]; then
|
|
echo -e "\\e[0Ksection_start:`date +%s`:nix_deps[collapsed=true]\\r\\e[0KFetching Nix dependencies for job"
|
|
nix build .#$1
|
|
source $(readlink -f result)
|
|
echo -e "\\e[0Ksection_end:`date +%s`:nix_deps\\r\\e[0K"
|
|
fi
|
|
echo -e "\\e[0Ksection_end:`date +%s`:nix_setup\\r\\e[0K"
|