Skip to content

Commit

Permalink
add github_access_token option
Browse files Browse the repository at this point in the history
I'm starting to see rate limit issues with GitHub Actions more
frequently so I propose to make this option more readily available.
  • Loading branch information
zimbatm committed Dec 29, 2022
1 parent a590bb1 commit b588e45
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand All @@ -65,8 +64,12 @@ To install Nix from any commit, go to [the corresponding installer_test action](
## Inputs (specify using `with:`)

- `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)

- `install_options`: Additional installer flags passed to the installer script.

- `nix_path`: set `NIX_PATH` environment variable, for example `nixpkgs=channel:nixos-unstable`

- `extra_nix_config`: append to `/etc/nix/nix.conf`
Expand Down
5 changes: 4 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ inputs:
nix_path:
description: 'Set NIX_PATH environment variable.'
extra_nix_config:
description: 'gets appended to `/etc/nix/nix.conf` if passed.'
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.'
branding:
color: 'blue'
icon: 'sun'
Expand All @@ -19,6 +21,7 @@ runs:
- run : ${{ github.action_path }}/install-nix.sh
shell: bash
env:
INPUT_GITHUB_ACCESS_TOKEN: ${{ inputs.github_access_token }}
INPUT_INSTALL_URL: ${{ inputs.install_url }}
INPUT_INSTALL_OPTIONS: ${{ inputs.install_options }}
INPUT_NIX_PATH: ${{ inputs.nix_path }}
Expand Down
4 changes: 4 additions & 0 deletions install-nix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit b588e45

Please sign in to comment.