mirror of
https://github.com/digital-asset/daml.git
synced 2024-09-20 09:17:43 +03:00
655e4b3b55
* Update CI nix version For `--option http2 false` to take effect requires Nix 2.3.2. CHANGELOG_BEGIN CHANGELOG_END * Set option `http2 = false` dev-env nix config This is less likely to overlook an instance than manually adding `--option http2 false` to each Nix invocation. Setting `--option htt2p false` also had no effect on the multi-user Nix installation on the Linux CI machines due to ``` WARNING: option '--disk_cache' was expanded to from both option '--config linux' (source /nix/store/2xnfb2l39d2b4nxw5vwmqz5hjwhw0caw-daml-bazelrc) and option '--config linux' (source /nix/store/2xnfb2l39d2b4nxw5vwmqz5hjwhw0caw-daml-bazelrc) ``` Co-authored-by: Andreas Herrmann <andreash87@gmx.ch>
57 lines
1.5 KiB
Bash
Executable File
57 lines
1.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
||
# Copyright (c) 2020 The DAML Authors. All rights reserved.
|
||
# SPDX-License-Identifier: Apache-2.0
|
||
|
||
# shellcheck disable=SC2174
|
||
|
||
# Installs nix on a fresh machine
|
||
set -euo pipefail
|
||
|
||
## Functions ##
|
||
|
||
step() {
|
||
echo "step: $*" >&2
|
||
}
|
||
|
||
## Main ##
|
||
|
||
cd "$(dirname "$0")/.."
|
||
|
||
if [[ ! -e /nix ]]; then
|
||
step "Installing Nix"
|
||
|
||
sudo mkdir -m 0755 /nix
|
||
sudo chown "$(id -u):$(id -g)" /nix
|
||
|
||
curl -sfL https://nixos.org/releases/nix/nix-2.3.2/install | bash
|
||
fi
|
||
|
||
# shellcheck source=../dev-env/lib/ensure-nix
|
||
source dev-env/lib/ensure-nix
|
||
|
||
export NIX_CONF_DIR=$PWD/dev-env/etc
|
||
|
||
step "Building dev-env dependencies"
|
||
|
||
# Nix cache downloads can sometimes be flaky and end with "unexpected end-of-file" so we
|
||
# repeat this a few times. There does not seem to be an option that we can pass to nix
|
||
# to make it retry itself. See https://github.com/NixOS/nix/issues/2794 for the issue requesting
|
||
# this feature.
|
||
NIX_FAILED=0
|
||
for i in `seq 10`; do
|
||
NIX_FAILED=0
|
||
nix-build nix -A tools -A cached 2>&1 | tee nix_log || NIX_FAILED=1
|
||
# It should be in the last line but let’s use the last 3 and wildcards
|
||
# to be robust against slight changes.
|
||
if [[ $NIX_FAILED -ne 0 ]] &&
|
||
([[ $(tail -n 3 nix_log) == *"unexpected end-of-file"* ]] ||
|
||
[[ $(tail -n 3 nix_log) == *"decompressing xz file"* ]]); then
|
||
echo "Restarting nix-build due to failed cache download"
|
||
continue
|
||
fi
|
||
break
|
||
done
|
||
if [[ $NIX_FAILED -ne 0 ]]; then
|
||
exit 1
|
||
fi
|