4848 HOMEBREW_NO_EMOJI : 1
4949 HOMEBREW_NO_ENV_HINTS : 1
5050 HOMEBREW_NO_INSTALL_CLEANUP : 1
51-
51+ NIX_CONFIG : |
52+ access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
53+
5254jobs :
5355 build-devbox :
5456 strategy :
5557 matrix :
56- os : [ubuntu-latest, macos-13 ]
58+ os : [ubuntu-latest, macos-latest ]
5759 runs-on : ${{ matrix.os }}
5860 steps :
5961 - uses : actions/checkout@v4
98100 golangci-lint :
99101 strategy :
100102 matrix :
101- os : [ubuntu-latest, macos-13 ]
103+ os : [ubuntu-latest, macos-latest ]
102104 runs-on : ${{ matrix.os }}
103105 timeout-minutes : 10
104106 steps :
@@ -126,7 +128,7 @@ jobs:
126128 matrix :
127129 is-main :
128130 - ${{ github.ref == 'refs/heads/main' && 'is-main' || 'not-main' }}
129- os : [ubuntu-latest, macos-13 ]
131+ os : [ubuntu-latest, macos-latest ]
130132 # This is an optimization that runs tests twice, with and without
131133 # the devbox.json tests. We can require the other tests to complete before
132134 # merging, while keeping the others as an additional non-required signal
@@ -138,7 +140,7 @@ jobs:
138140 nix-version : ["2.12.0", "2.19.2", "2.30.2"]
139141 exclude :
140142 # Only runs tests on macos if explicitly requested, or on a schedule
141- - os : " ${{ (inputs.run-mac-tests || github.event.schedule != '') && 'dummy' || 'macos-13 ' }}"
143+ - os : " ${{ (inputs.run-mac-tests || github.event.schedule != '') && 'dummy' || 'macos-latest ' }}"
142144
143145
144146 runs-on : ${{ matrix.os }}
@@ -176,6 +178,30 @@ jobs:
176178 uses : jetify-com/devbox-install-action@jl/migrate-installer
177179 with :
178180 enable-cache : true
181+ - name : Setup Nix GitHub authentication
182+ run : |
183+ # Setup github authentication to ensure Github's rate limits are not hit
184+ # For macOS, we need to configure the system-wide nix.conf because the Nix daemon
185+ # runs as a different user and doesn't read the user's ~/.config/nix/nix.conf
186+ if [ "$RUNNER_OS" == "macOS" ]; then
187+ echo "Configuring system-wide Nix config for macOS daemon"
188+ # Ensure /etc/nix directory exists
189+ if [ ! -d /etc/nix ]; then
190+ sudo mkdir -p /etc/nix
191+ fi
192+ # Check if file exists, create it if not
193+ if [ ! -f /etc/nix/nix.conf ]; then
194+ echo "# Nix configuration" | sudo tee /etc/nix/nix.conf > /dev/null
195+ fi
196+ echo "access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}" | sudo tee -a /etc/nix/nix.conf
197+ # Restart nix daemon to pick up the new configuration
198+ sudo launchctl stop org.nixos.nix-daemon || true
199+ sudo launchctl start org.nixos.nix-daemon || true
200+ sleep 2 # Give daemon time to restart
201+ fi
202+ # For Linux and as a backup for macOS, also configure user config
203+ mkdir -p ~/.config/nix
204+ echo "access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}" > ~/.config/nix/nix.conf
179205 - name : Run fast tests
180206 if : matrix.run-project-tests == 'project-tests-off'
181207 run : |
@@ -197,7 +223,7 @@ jobs:
197223 needs : build-devbox
198224 strategy :
199225 matrix :
200- os : [ubuntu-latest, macos-13 ]
226+ os : [ubuntu-latest, macos-latest ]
201227 use-detsys : [true, false]
202228 runs-on : ${{ matrix.os }}
203229 steps :
@@ -215,12 +241,28 @@ jobs:
215241 export NIX_INSTALLER_NO_CHANNEL_ADD=1
216242 export DEVBOX_FEATURE_DETSYS_INSTALLER=${{ matrix.use-detsys }}
217243
218- # Setup github authentication to ensure Github's rate limits are not hit.
219- # If this works, we can consider refactoring this into a reusable github action helper.
244+ # Setup github authentication BEFORE running devbox to ensure Github's rate limits are not hit.
245+ # Configure user config first (Nix installer will respect this)
220246 mkdir -p ~/.config/nix
221247 echo "access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}" > ~/.config/nix/nix.conf
222248
249+ # Run devbox which will auto-install Nix if needed
223250 devbox run echo "Installing packages..."
251+
252+ # After Nix is installed, configure system-wide config for the daemon on macOS
253+ if [ "$RUNNER_OS" == "macOS" ]; then
254+ echo "Configuring system-wide Nix config for macOS daemon"
255+ # Check if file exists, create directory if needed
256+ if [ ! -f /etc/nix/nix.conf ]; then
257+ sudo mkdir -p /etc/nix
258+ echo "# Nix configuration" | sudo tee /etc/nix/nix.conf > /dev/null
259+ fi
260+ echo "access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}" | sudo tee -a /etc/nix/nix.conf
261+ # Restart nix daemon to pick up the new configuration
262+ sudo launchctl stop org.nixos.nix-daemon || true
263+ sudo launchctl start org.nixos.nix-daemon || true
264+ sleep 2 # Give daemon time to restart
265+ fi
224266 - name : Test removing package
225267 run : devbox rm go
226268
@@ -230,7 +272,7 @@ jobs:
230272 needs : build-devbox
231273 strategy :
232274 matrix :
233- os : [ubuntu-latest, macos-13 ]
275+ os : [ubuntu-latest, macos-latest ]
234276 nix-version : [2.15.1, 2.16.1, 2.17.0, 2.18.0, 2.19.2, 2.24.7]
235277 runs-on : ${{ matrix.os }}
236278 steps :
0 commit comments