@@ -110,35 +110,17 @@ cachix use peerswap
110110 - Compare build times before/after Cachix
111111 - Expected improvement: 50-80% faster builds
112112
113- ## How It Works
113+ ### 4. Local Cache Push
114114
115- ### CI/CD Pipeline
116-
117- The GitHub Actions workflow (`.github/workflows/ci.yml`) includes:
118-
119- ```yaml
120- - uses: cachix/install-nix-action@v31
121- with:
122- github_access_token: ${{ secrets.GITHUB_TOKEN }}
123- nix_path: nixpkgs=channel:nixos-unstable
124- extra_nix_config: |
125- experimental-features = nix-command flakes
126-
127- - uses: cachix/cachix-action@v16
128- with:
129- name: peerswap
130- authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
131- extraPullNames: nix-community
132- useDaemon: true
133- skipPush: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository }}
134- ```
115+ To push from local development to the cache:
135116
136- ### Security Model
117+ ```bash
118+ # Create a profile and push to cache
119+ nix develop --profile dev-profile
120+ cachix push peerswap dev-profile
121+ ```
137122
138- - ** Public cache** : Anyone can pull (read) from the cache
139- - ** Authenticated push** : Only CI with valid token can push
140- - ** Fork safety** : External forks can read but cannot push
141- - ** Background uploads** : Non-blocking cache population
123+ ## How It Works
142124
143125### Local Development
144126
@@ -153,78 +135,6 @@ if command -v cachix >/dev/null 2>&1; then
153135fi
154136```
155137
156- ## Troubleshooting
157-
158- ### Common Issues
159-
160- 1 . ** "Secret not found" in CI** :
161- - Verify ` CACHIX_AUTH_TOKEN ` is correctly named in repository secrets
162- - Check token has not expired
163-
164- 2 . ** "Permission denied" when pushing** :
165- - Ensure token has "Push" permission
166- - Verify cache name matches exactly: ` peerswap `
167-
168- 3 . ** Fork PRs cannot push** :
169- - This is expected security behavior
170- - Forks can read from cache but cannot write
171- - No action needed
172-
173- 4 . ** Slow builds despite cache** :
174- - Check if cache is being used: ` nix build --show-trace `
175- - Verify substituters in ` ~/.config/nix/nix.conf `
176-
177- ### Advanced Configuration
178-
179- 1 . ** Custom substituters** :
180- ``` bash
181- # Add to ~/.config/nix/nix.conf
182- substituters = https://cache.nixos.org/ https://peerswap.cachix.org
183- trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= peerswap.cachix.org-1:...
184- ```
185-
186- 2 . ** Local cache management** :
187- ``` bash
188- # Clear local cache
189- nix-collect-garbage -d
190-
191- # Check cache usage
192- du -sh /nix/store
193- ```
194-
195- ## Maintenance
196-
197- ### Regular Tasks
198-
199- 1 . ** Monitor cache usage** :
200- - Check Cachix dashboard for storage usage
201- - Clean up old artifacts if needed
202-
203- 2 . ** Token rotation** :
204- - Rotate auth tokens periodically (recommended: every 6 months)
205- - Update GitHub secrets accordingly
206-
207- 3 . ** Performance monitoring** :
208- - Track CI build times
209- - Monitor cache hit rates
210-
211- ### Updates
212-
213- When updating Nix-related dependencies:
214-
215- 1 . Update ` flake.lock ` :
216- ``` bash
217- nix flake update
218- ```
219-
220- 2 . Test locally:
221- ``` bash
222- nix develop
223- make test
224- ```
225-
226- 3 . Verify CI builds successfully with new dependencies
227-
228138## Support
229139
230140For issues related to:
@@ -238,9 +148,23 @@ For issues related to:
238148- [ Cachix Documentation] ( https://docs.cachix.org/ )
239149- [ GitHub Actions + Nix] ( https://nix.dev/guides/recipes/continuous-integration-github-actions )
240150
151+ ## Troubleshooting
152+
153+ ### Common Issues
241154
242- to push
243- nix develop --profile dev-profile && cachix push mycache dev-profile
155+ ** Issue** : ` /tmp/xxx ` directory error
156+ ** Solution** : Manually create the required directory
157+ ** Reference** : https://github.com/arrterian/nix-env-selector/issues/95
244158
245- /tmp/xxx というエラーが出た場合は、手動でdirを作成してください
246- https://github.com/arrterian/nix-env-selector/issues/95
159+ ** Issue** : Cachix authentication failed
160+ ** Solution** : Ensure you're logged in to Cachix:
161+ ``` bash
162+ cachix authtoken < your-token>
163+ ```
164+
165+ ** Issue** : Nix flakes not enabled
166+ ** Solution** : Enable experimental features:
167+ ``` bash
168+ mkdir -p ~ /.config/nix
169+ echo " experimental-features = nix-command flakes" >> ~ /.config/nix/nix.conf
170+ ```
0 commit comments