add extra_nix_config options

This also cleans the install-nix.sh script a bit
This commit is contained in:
zimbatm 2020-08-25 18:07:38 +02:00
parent 3559d01d05
commit dad23f2092
No known key found for this signature in database
GPG key ID: 71BAF6D40C1D63D7
3 changed files with 17 additions and 5 deletions

View file

@ -35,6 +35,7 @@ with developers.
- `nix_path`: set `NIX_PATH` environment variable (if set `skip_adding_nixpkgs_channel` will be implicitly enabled) - `nix_path`: set `NIX_PATH` environment variable (if set `skip_adding_nixpkgs_channel` will be implicitly enabled)
- `skip_adding_nixpkgs_channel`: set to `true` to skip adding nixpkgs-unstable channel (and save ~5s for each job build) - `skip_adding_nixpkgs_channel`: set to `true` to skip adding nixpkgs-unstable channel (and save ~5s for each job build)
- `extra_nix_config`: gets appended to `/etc/nix/nix.conf` if passed.
--- ---

View file

@ -8,6 +8,8 @@ inputs:
description: 'Set NIX_PATH environment variable. If set "skip_adding_nixpkgs_channel" will be implicitly enabled' description: 'Set NIX_PATH environment variable. If set "skip_adding_nixpkgs_channel" will be implicitly enabled'
skip_adding_nixpkgs_channel: skip_adding_nixpkgs_channel:
description: 'Skip adding nixpkgs-unstable channel' description: 'Skip adding nixpkgs-unstable channel'
extra_nix_config:
description: 'gets appended to `/etc/nix/nix.conf` if passed.'
branding: branding:
color: 'blue' color: 'blue'
icon: 'sun' icon: 'sun'

View file

@ -5,16 +5,25 @@ set -euo pipefail
sudo sh -c 'echo max-jobs = auto >> /tmp/nix.conf' sudo sh -c 'echo max-jobs = auto >> /tmp/nix.conf'
# Allow binary caches for runner user # Allow binary caches for runner user
sudo sh -c 'echo trusted-users = root runner >> /tmp/nix.conf' sudo sh -c 'echo trusted-users = root runner >> /tmp/nix.conf'
if [[ -n $INPUT_EXTRA_NIX_CONFIG ]]; then
echo "$INPUT_EXTRA_NIX_CONFIG" >> /tmp/nix.conf
fi
if [[ $INPUT_SKIP_ADDING_NIXPKGS_CHANNEL = "true" || $INPUT_NIX_PATH != "" ]]; then install_options=(
extra_cmd=--no-channel-add --daemon
--daemon-user-count 4
--nix-extra-conf-file /tmp/nix.conf
--darwin-use-unencrypted-nix-store-volume
)
if [[ $INPUT_SKIP_ADDING_NIXPKGS_CHANNEL = "true" || -n $INPUT_NIX_PATH ]]; then
install_options+=(--no-channel-add)
else else
extra_cmd=
INPUT_NIX_PATH="/nix/var/nix/profiles/per-user/root/channels" INPUT_NIX_PATH="/nix/var/nix/profiles/per-user/root/channels"
fi fi
sh <(curl --retry 5 --retry-connrefused -L ${INPUT_INSTALL_URL:-https://nixos.org/nix/install}) \ sh <(curl --retry 5 --retry-connrefused -L "${INPUT_INSTALL_URL:-https://nixos.org/nix/install}") \
--daemon --daemon-user-count 4 --nix-extra-conf-file /tmp/nix.conf --darwin-use-unencrypted-nix-store-volume $extra_cmd "${install_options[@]}"
if [[ $OSTYPE =~ darwin ]]; then if [[ $OSTYPE =~ darwin ]]; then
# Disable spotlight indexing of /nix to speed up performance # Disable spotlight indexing of /nix to speed up performance