Support self-hosted runners and always skip adding a channel

This commit is contained in:
Domen Kožar 2020-09-21 13:51:23 +02:00
parent 5a2cbacfff
commit 775aed5fcb
No known key found for this signature in database
GPG key ID: C2FFBCAFD2C24246
4 changed files with 49 additions and 35 deletions

View file

@ -7,8 +7,8 @@ add_config() {
}
# Set jobs to number of cores
add_config "max-jobs = auto"
# Allow binary caches for runner user
add_config "trusted-users = root runner"
# Allow binary caches for user
add_config "trusted-users = root $USER"
# Append extra nix configuration if provided
if [[ $INPUT_EXTRA_NIX_CONFIG != "" ]]; then
add_config "$INPUT_EXTRA_NIX_CONFIG"
@ -18,19 +18,17 @@ fi
installer_options=(
--daemon
--daemon-user-count 4
--no-channel-add
--darwin-use-unencrypted-nix-store-volume
--nix-extra-conf-file /tmp/nix.conf
)
if [[ $INPUT_SKIP_ADDING_NIXPKGS_CHANNEL = "true" || $INPUT_NIX_PATH != "" ]]; then
installer_options+=(--no-channel-add)
else
INPUT_NIX_PATH="/nix/var/nix/profiles/per-user/root/channels"
# On self-hosted runners we don't need to install more than once
if [ ! -d "/nix/store" ]
then
sh <(curl --retry 5 --retry-connrefused -L "${INPUT_INSTALL_URL:-https://nixos.org/nix/install}") "${installer_options[@]}"
fi
sh <(curl --retry 5 --retry-connrefused -L "${INPUT_INSTALL_URL:-https://nixos.org/nix/install}") \
"${installer_options[@]}"
if [[ $OSTYPE =~ darwin ]]; then
# Disable spotlight indexing of /nix to speed up performance
sudo mdutil -i off /nix
@ -43,7 +41,7 @@ if [[ $OSTYPE =~ darwin ]]; then
fi
# Set paths
echo "::add-path::/nix/var/nix/profiles/per-user/runner/profile/bin"
echo "::add-path::/nix/var/nix/profiles/per-user/$USER/profile/bin"
echo "::add-path::/nix/var/nix/profiles/default/bin"
if [[ $INPUT_NIX_PATH != "" ]]; then