Check Nix Updates #34
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Check Nix Updates | |
| on: | |
| schedule: | |
| # Run every Monday at 09:00 UTC | |
| - cron: '0 9 * * 1' | |
| workflow_dispatch: | |
| push: | |
| branches: [master] | |
| paths: | |
| - 'flake.lock' | |
| - '.github/workflows/check-nix-updates.yml' | |
| pull_request: | |
| paths: | |
| - 'flake.lock' | |
| - 'flake.nix' | |
| - '.github/workflows/check-nix-updates.yml' | |
| jobs: | |
| check-flake: | |
| name: Check Flake Health | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Check flake | |
| uses: DeterminateSystems/flake-checker-action@v9 | |
| with: | |
| fail-mode: false # Don't fail the workflow, just report | |
| send-statistics: false # Don't send telemetry | |
| check-updates: | |
| name: Check for Updates | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install Nix | |
| uses: DeterminateSystems/nix-installer-action@v9 | |
| - name: Setup Nix cache | |
| uses: DeterminateSystems/magic-nix-cache-action@v2 | |
| - name: Check for updates manually | |
| run: | | |
| echo "🔍 Checking for Nix flake updates..." | |
| # Configure git to use the GitHub token for authentication | |
| git config --global url."https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/".insteadOf "https://github.com/" | |
| # Save current lock file | |
| cp flake.lock flake.lock.original | |
| # Try updating | |
| nix flake update --accept-flake-config || { | |
| echo "⚠️ Could not check for updates (this may happen with private repos or rate limits)" | |
| echo "To check manually, run: nix flake update" | |
| mv flake.lock.original flake.lock | |
| exit 0 | |
| } | |
| # Check if anything changed | |
| if ! cmp -s flake.lock flake.lock.original; then | |
| echo "📦 Updates are available!" | |
| echo "" | |
| echo "To see what changed, run:" | |
| echo '```bash' | |
| echo 'git diff flake.lock' | |
| echo '```' | |
| echo "" | |
| echo "### How to update:" | |
| echo '```bash' | |
| echo 'nix flake update' | |
| echo 'git add flake.lock' | |
| echo 'git commit -m "chore: update Nix flake dependencies"' | |
| echo '```' | |
| # Restore original to avoid committing changes | |
| mv flake.lock.original flake.lock | |
| else | |
| echo "✅ All Nix flake inputs are up to date!" | |
| rm flake.lock.original | |
| fi | |
| - name: Test current flake | |
| run: | | |
| echo "🧪 Testing current flake configuration..." | |
| nix flake check | |
| echo "✅ Flake check passed" |