Skip to content

Commit b588e45

Browse files
committed
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.
1 parent a590bb1 commit b588e45

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ jobs:
5555
- uses: actions/checkout@v3
5656
- uses: cachix/install-nix-action@v18
5757
with:
58-
extra_nix_config: |
59-
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
58+
github_access_token: ${{ secrets.GITHUB_TOKEN }}
6059
- run: nix build
6160
- run: nix flake check
6261
```
@@ -65,8 +64,12 @@ To install Nix from any commit, go to [the corresponding installer_test action](
6564
6665
## Inputs (specify using `with:`)
6766

67+
- `github_access_token`: configure nix to pull from github using the given github token. This helps work around rate limit issues.
68+
6869
- `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)
6970

71+
- `install_options`: Additional installer flags passed to the installer script.
72+
7073
- `nix_path`: set `NIX_PATH` environment variable, for example `nixpkgs=channel:nixos-unstable`
7174

7275
- `extra_nix_config`: append to `/etc/nix/nix.conf`

action.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ inputs:
99
nix_path:
1010
description: 'Set NIX_PATH environment variable.'
1111
extra_nix_config:
12-
description: 'gets appended to `/etc/nix/nix.conf` if passed.'
12+
description: 'Gets appended to `/etc/nix/nix.conf` if passed.'
13+
github_access_token:
14+
description: 'Configure nix to pull from github using the given github token.'
1315
branding:
1416
color: 'blue'
1517
icon: 'sun'
@@ -19,6 +21,7 @@ runs:
1921
- run : ${{ github.action_path }}/install-nix.sh
2022
shell: bash
2123
env:
24+
INPUT_GITHUB_ACCESS_TOKEN: ${{ inputs.github_access_token }}
2225
INPUT_INSTALL_URL: ${{ inputs.install_url }}
2326
INPUT_INSTALL_OPTIONS: ${{ inputs.install_options }}
2427
INPUT_NIX_PATH: ${{ inputs.nix_path }}

install-nix.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ add_config() {
2121
add_config "max-jobs = auto"
2222
# Allow binary caches for user
2323
add_config "trusted-users = root $USER"
24+
# Add github access token
25+
if [[ $INPUT_GITHUB_ACCESS_TOKEN != "" ]]; then
26+
add_config "access-tokens" "github.com=$INPUT_GITHUB_ACCESS_TOKEN"
27+
fi
2428
# Append extra nix configuration if provided
2529
if [[ $INPUT_EXTRA_NIX_CONFIG != "" ]]; then
2630
add_config "$INPUT_EXTRA_NIX_CONFIG"

0 commit comments

Comments
 (0)