From c04fcbc1790b0d7beebb69ed234fc4d8bdcac953 Mon Sep 17 00:00:00 2001 From: zimbatm Date: Tue, 27 Dec 2022 19:51:55 +0100 Subject: [PATCH] add github_access_token option I'm starting to see rate limit issues with GitHub Actions more frequently so I propose to make this option more readily available. --- README.md | 11 +++++++---- action.yml | 13 ++++++++----- install-nix.sh | 4 ++++ 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 2b5509a..e1ea4d4 100644 --- a/README.md +++ b/README.md @@ -55,8 +55,7 @@ jobs: - uses: actions/checkout@v3 - uses: cachix/install-nix-action@v18 with: - extra_nix_config: | - access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} + github_access_token: ${{ secrets.GITHUB_TOKEN }} - run: nix build - run: nix flake check ``` @@ -65,11 +64,15 @@ To install Nix from any commit, go to [the corresponding installer_test action]( ## Inputs (specify using `with:`) +- `extra_nix_config`: append to `/etc/nix/nix.conf` + +- `github_access_token`: configure nix to pull from github using the given github token. This helps work around rate limit issues. + - `install_url`: specify URL to install Nix from (useful for testing non-stable releases or pinning Nix for example https://releases.nixos.org/nix/nix-2.3.7/install) -- `nix_path`: set `NIX_PATH` environment variable, for example `nixpkgs=channel:nixos-unstable` +- `install_options`: Additional installer flags passed to the installer script. -- `extra_nix_config`: append to `/etc/nix/nix.conf` +- `nix_path`: set `NIX_PATH` environment variable, for example `nixpkgs=channel:nixos-unstable` --- diff --git a/action.yml b/action.yml index a108b19..fe1a740 100644 --- a/action.yml +++ b/action.yml @@ -2,14 +2,16 @@ name: 'Install Nix' description: 'Installs Nix on GitHub Actions for the supported platforms: Linux and macOS.' author: 'Domen Kožar' inputs: + extra_nix_config: + description: 'Gets appended to `/etc/nix/nix.conf` if passed.' + github_access_token: + description: 'Configure nix to pull from github using the given github token.' install_url: description: 'Installation URL that will contain a script to install Nix.' install_options: description: 'Additional installer flags passed to the installer script.' nix_path: description: 'Set NIX_PATH environment variable.' - extra_nix_config: - description: 'gets appended to `/etc/nix/nix.conf` if passed.' branding: color: 'blue' icon: 'sun' @@ -19,7 +21,8 @@ runs: - run : ${{ github.action_path }}/install-nix.sh shell: bash env: - INPUT_INSTALL_URL: ${{ inputs.install_url }} - INPUT_INSTALL_OPTIONS: ${{ inputs.install_options }} - INPUT_NIX_PATH: ${{ inputs.nix_path }} INPUT_EXTRA_NIX_CONFIG: ${{ inputs.extra_nix_config }} + INPUT_GITHUB_ACCESS_TOKEN: ${{ inputs.github_access_token }} + INPUT_INSTALL_OPTIONS: ${{ inputs.install_options }} + INPUT_INSTALL_URL: ${{ inputs.install_url }} + INPUT_NIX_PATH: ${{ inputs.nix_path }} diff --git a/install-nix.sh b/install-nix.sh index 482f192..b2d254f 100755 --- a/install-nix.sh +++ b/install-nix.sh @@ -21,6 +21,10 @@ add_config() { add_config "max-jobs = auto" # Allow binary caches for user add_config "trusted-users = root $USER" +# Add github access token +if [[ $INPUT_GITHUB_ACCESS_TOKEN != "" ]]; then + add_config "access-tokens" "github.com=$INPUT_GITHUB_ACCESS_TOKEN" +fi # Append extra nix configuration if provided if [[ $INPUT_EXTRA_NIX_CONFIG != "" ]]; then add_config "$INPUT_EXTRA_NIX_CONFIG"