Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,17 @@ jobs:
sha256-checksum: '169836de22c41a1c68ac5a43e0514d4021137647c7c08ee8bd921faa430ee286'
project-path: 'testdata'
disable-nix-access-token: "${{ github.ref != 'refs/heads/main' }}"

test-action-with-extra-nix-config:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install devbox with extra nix config "user-agent-suffix = test-suffix"
uses: ./
with:
devbox-version: 0.13.6
project-path: 'testdata'
extra-nix-config: user-agent-suffix = test-suffix
- name: Check nix user-agent-suffix config
run: |
[[ "$(nix config show user-agent-suffix)" == "test-suffix" ]]
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ jobs:
| sha256-checksum | Specify an explicit checksum for the devbox binary | |
| disable-nix-access-token | Disable configuration of nix access-tokens with the GitHub token used in the workflow | false |
| skip-nix-installation | Skip the installation of nix | false |
| extra-nix-config | Gets appended to `nix.conf` if passed | |

### Example Configuration
### Example Configurations

Here's an example job with all inputs:
Here's an example job with most inputs:

```
- name: Install devbox
Expand All @@ -56,3 +57,17 @@ Here's an example job with all inputs:
disable-nix-access-token: 'false'
sha256-checksum: <checksum>
```

#### Usage on a GitHub Enterprise Server

On a privately hosted GitHub Enterprise Server, the `github.token` available in the context is not valid for accessing `api.github.com`,
which can lead to failures due to the rate-limit for unauthenticated requests. To work around this, you can provide a personal access token
for `api.github.com` in the `extra-nix-config` input.
Additionally, it might be necessary to provide a token for your GitHub Enterprise Server, if you are using Nix packages from there.

```
- name: Install devbox
uses: jetify-com/[email protected]
with:
extra-nix-config: access-tokens = my-github-enterprise-server.example.com=${{ github.token }} github.com=${{ secrets.MY_GITHUB_COM_TOKEN }}
```
14 changes: 12 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ inputs:
skip-nix-installation: # 'true' or 'false'
description: 'Skip the installation of nix'
default: 'false'
extra-nix-config:
description: 'Gets appended to `nix.conf` if passed'
default: ''

runs:
using: "composite"
Expand Down Expand Up @@ -126,12 +129,19 @@ runs:
fi

- name: Configure nix access-tokens
if: inputs.disable-nix-access-token == 'false'
if: inputs.disable-nix-access-token == 'false' && github.server_url == 'https://github.com'
Copy link
Contributor Author

@silvestre silvestre Mar 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is more of a nice to have: If you are running this action on a GitHub Enterprise Server, configuring the github.token as nix access token to github.com makes no sense, so we can skip it, and at least make the unauthenticated access work, without requiring the user to set disable-nix-access-token.

shell: bash
run: |
mkdir -p ~/.config/nix
echo "access-tokens = github.com=${{ github.token }}" >> ~/.config/nix/nix.conf

- name: Configure nix extra config
if: inputs.extra-nix-config != ''
shell: bash
run: |
mkdir -p ~/.config/nix
echo "${{ inputs.extra-nix-config }}" >> ~/.config/nix/nix.conf

- name: Install nix
if: inputs.skip-nix-installation == 'false'
uses: DeterminateSystems/nix-installer-action@e50d5f73bfe71c2dd0aa4218de8f4afa59f8f81d # v16
Expand Down Expand Up @@ -165,7 +175,7 @@ runs:
shell: bash
run: |
devbox run --config=${{ inputs.project-path }} -- echo "Packages installed!"

- name: List nix store cache on failure
shell: bash
if: failure()
Expand Down
Loading