mirror of
https://github.com/cachix/install-nix-action.git
synced 2024-11-25 18:08:03 +00:00
commit
d045d9f5d8
1 changed files with 18 additions and 9 deletions
|
@ -6,9 +6,13 @@ if type -p nix &>/dev/null ; then
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Create a temporary workdir
|
||||||
|
workdir=$(mktemp -d)
|
||||||
|
trap 'rm -rf "$workdir"' EXIT
|
||||||
|
|
||||||
# Configure Nix
|
# Configure Nix
|
||||||
add_config() {
|
add_config() {
|
||||||
echo "$1" | tee -a /tmp/nix.conf >/dev/null
|
echo "$1" | tee -a "$workdir/nix.conf" >/dev/null
|
||||||
}
|
}
|
||||||
# Set jobs to number of cores
|
# Set jobs to number of cores
|
||||||
add_config "max-jobs = auto"
|
add_config "max-jobs = auto"
|
||||||
|
@ -26,14 +30,14 @@ fi
|
||||||
installer_options=(
|
installer_options=(
|
||||||
--no-channel-add
|
--no-channel-add
|
||||||
--darwin-use-unencrypted-nix-store-volume
|
--darwin-use-unencrypted-nix-store-volume
|
||||||
--nix-extra-conf-file /tmp/nix.conf
|
--nix-extra-conf-file "$workdir/nix.conf"
|
||||||
)
|
)
|
||||||
|
|
||||||
# only use the nix-daemon settings if on darwin (which get ignored) or systemd is supported
|
# only use the nix-daemon settings if on darwin (which get ignored) or systemd is supported
|
||||||
if [[ $OSTYPE =~ darwin || -e /run/systemd/system ]]; then
|
if [[ $OSTYPE =~ darwin || -e /run/systemd/system ]]; then
|
||||||
installer_options+=(
|
installer_options+=(
|
||||||
--daemon
|
--daemon
|
||||||
--daemon-user-count `python -c 'import multiprocessing as mp; print(mp.cpu_count() * 2)'`
|
--daemon-user-count "$(python -c 'import multiprocessing as mp; print(mp.cpu_count() * 2)')"
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
# "fix" the following error when running nix*
|
# "fix" the following error when running nix*
|
||||||
|
@ -42,20 +46,25 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $INPUT_INSTALL_OPTIONS != "" ]]; then
|
if [[ $INPUT_INSTALL_OPTIONS != "" ]]; then
|
||||||
IFS=' ' read -r -a extra_installer_options <<< $INPUT_INSTALL_OPTIONS
|
IFS=' ' read -r -a extra_installer_options <<< "$INPUT_INSTALL_OPTIONS"
|
||||||
installer_options=("${extra_installer_options[@]}" "${installer_options[@]}")
|
installer_options=("${extra_installer_options[@]}" "${installer_options[@]}")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "installer options: ${installer_options[@]}"
|
echo "installer options: ${installer_options[*]}"
|
||||||
|
|
||||||
# There is --retry-on-errors, but only newer curl versions support that
|
# There is --retry-on-errors, but only newer curl versions support that
|
||||||
until curl -o /tmp/install -v --fail --retry 5 --retry-connrefused -L "${INPUT_INSTALL_URL:-https://nixos.org/nix/install}"
|
curl_retries=5
|
||||||
|
while ! curl -o "$workdir/install" -v --fail -L "${INPUT_INSTALL_URL:-https://nixos.org/nix/install}"
|
||||||
do
|
do
|
||||||
sleep 1
|
sleep 1
|
||||||
|
((curl_retries--))
|
||||||
|
if [[ $curl_retries -le 0 ]]; then
|
||||||
|
echo "curl retries failed" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
chmod +x /tmp/install
|
sh "$workdir/install" "${installer_options[@]}"
|
||||||
sh /tmp/install "${installer_options[@]}"
|
|
||||||
|
|
||||||
if [[ $OSTYPE =~ darwin ]]; then
|
if [[ $OSTYPE =~ darwin ]]; then
|
||||||
# macOS needs certificates hints
|
# macOS needs certificates hints
|
||||||
|
|
Loading…
Reference in a new issue