@@ -39,15 +39,18 @@ defaults:
3939 shell : bash
4040
4141env :
42- HOMEBREW_GITHUB_API_TOKEN : ${{ secrets.GITHUB_TOKEN }}
42+ DEVBOX_DEBUG : 1
4343 DEVBOX_GITHUB_API_TOKEN : ${{ secrets.GITHUB_TOKEN }}
44+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
45+ HOMEBREW_GITHUB_API_TOKEN : ${{ secrets.GITHUB_TOKEN }}
4446 HOMEBREW_NO_ANALYTICS : 1
4547 HOMEBREW_NO_AUTO_UPDATE : 1
4648 HOMEBREW_NO_EMOJI : 1
4749 HOMEBREW_NO_ENV_HINTS : 1
4850 HOMEBREW_NO_INSTALL_CLEANUP : 1
49- DEVBOX_DEBUG : 1
50-
51+ NIX_CONFIG : |
52+ access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
53+
5154jobs :
5255 build-devbox :
5356 strategy :
@@ -82,10 +85,13 @@ jobs:
8285 runs-on : ubuntu-latest
8386 steps :
8487 - uses : actions/checkout@v4
85- - uses : DeterminateSystems/nix-installer-action@main
88+ - name : Install devbox
89+ uses : jetify-com/devbox-install-action@jl/migrate-installer
90+ with :
91+ enable-cache : true
8692 - name : Build flake
8793 run : |
88- if ! nix build . ; then
94+ if ! devbox run build-flake ; then
8995 echo "::warning::If this fails, you probably have to run 'devbox run update-hash'"
9096 exit 1
9197 fi
@@ -101,7 +107,7 @@ jobs:
101107 - uses : actions/checkout@v4
102108
103109 - name : Install devbox
104- uses : jetify-com/devbox-install-action@v0.11.0
110+ uses : jetify-com/devbox-install-action@jl/migrate-installer
105111 with :
106112 enable-cache : true
107113
@@ -131,7 +137,7 @@ jobs:
131137 # 1. the oldest supported nix version (which is 2.9.0? But determinate-systems installer has 2.12.0)
132138 # 2. nix 2.19.2: version before nix profile changes
133139 # 2. latest nix version (note, 2.20.1 introduced a new profile change)
134- nix-version : ["2.12.0", "2.19.2", "2.20.1 "]
140+ nix-version : ["2.12.0", "2.19.2", "2.30.2 "]
135141 exclude :
136142 # Only runs tests on macos if explicitly requested, or on a schedule
137143 - os : " ${{ (inputs.run-mac-tests || github.event.schedule != '') && 'dummy' || 'macos-13' }}"
@@ -145,16 +151,12 @@ jobs:
145151 DEVBOX_DEBUG : ${{ (matrix.run-project-tests == 'project-tests-off' || inputs.example-debug) && '1' || '0' }}
146152 DEVBOX_GOLANG_TEST_TIMEOUT : " ${{ (github.ref == 'refs/heads/main' || inputs.run-mac-tests) && '1h' || '30m' }}"
147153 steps :
148- - name : Maximize build disk space
149- uses : easimon/maximize-build-space@v10
150- if : matrix.os == 'ubuntu-latest'
151- with :
152- root-reserve-mb : 32768
153- temp-reserve-mb : 10000
154- remove-dotnet : true
155- remove-android : true
156- remove-haskell : true
157- remove-codeql : true
154+ - name : clear directories to reduce disk usage
155+ # https://github.com/actions/runner-images/issues/2840#issuecomment-1284059930
156+ run : |
157+ sudo rm -rf /usr/share/dotnet
158+ sudo rm -rf "$AGENT_TOOLSDIRECTORY"
159+
158160 - uses : actions/checkout@v4
159161 - name : Mount golang cache
160162 uses : actions/cache@v4
@@ -173,9 +175,33 @@ jobs:
173175 brew install dash zsh
174176 fi
175177 - name : Install devbox
176- uses : jetify-com/devbox-install-action@v0.11.0
178+ 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 : |
@@ -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
0 commit comments