chore(flake/nur): e5ac01ee -> 183ab848 #17572
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 and Build Flake Config | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| env: | |
| EXTRA_NIX_CONFIG: | | |
| auto-optimise-store = true | |
| experimental-features = nix-command flakes | |
| max-jobs = auto | |
| download-buffer-size = 500000000 | |
| substituters = https://rishabh5321.cachix.org https://cache.nixos.org https://nixpkgs-wayland.cachix.org https://nix-config.cachix.org https://nix-community.cachix.org https://hyprland.cachix.org https://nixpkgs-wayland.cachix.org https://nix-gaming.cachix.org | |
| trusted-public-keys = rishabh5321.cachix.org-1:mxfBIH2XElE6ieFXXYBA9Ame4mVTbAf1TGR843siggk= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= nixpkgs-wayland.cachix.org-1:3lwxaILxMRkVhehr5StQprHdEo4IrE8sRho9R9HOLYA= nix-config.cachix.org-1:Vd6raEuldeIZpttVQfrUbLvXJHzzzkS0pezXCVVjDG4= nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs= hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc= nixpkgs-wayland.cachix.org-1:3lwxaILxMRkVhehr5StQprHdEo4IrE8sRho9R9HOLYA= nix-gaming.cachix.org-1:nbjlureqMbRAxR1gJ/f3hxemL9svXaZF/Ees8vCUUs4= | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| workflow_dispatch: | |
| inputs: | |
| specific_host: | |
| description: "Build only a specific host (leave empty for all)" | |
| required: false | |
| type: string | |
| timeout_minutes: | |
| description: "Timeout for build jobs in minutes" | |
| required: false | |
| type: number | |
| default: 180 | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| prepare_build: | |
| name: Prepare Build | |
| runs-on: ubuntu-latest | |
| outputs: | |
| matrix: ${{ steps.set-matrix.outputs.matrix }} | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v6 | |
| - name: Install Nix | |
| uses: DeterminateSystems/nix-installer-action@v22 | |
| with: | |
| extra-conf: ${{ env.EXTRA_NIX_CONFIG }} | |
| - name: Run Flake Check | |
| uses: DeterminateSystems/flake-checker-action@main | |
| - name: Flake check | |
| run: | | |
| nix flake check | |
| - name: Generate matrix from nixosConfigurations | |
| id: set-matrix | |
| run: | | |
| if [ -n "${{ github.event.inputs.specific_host }}" ]; then | |
| # If a specific host was provided, only build that one | |
| HOSTS=$(echo '["${{ github.event.inputs.specific_host }}"]' | jq -c .) | |
| else | |
| # Otherwise build all hosts from the flake | |
| HOSTS=$(nix eval --json .#nixosConfigurations --apply 'builtins.attrNames' | jq -c .) | |
| fi | |
| echo "matrix={\"hostname\":$HOSTS}" >> "$GITHUB_OUTPUT" | |
| build_config: | |
| name: Build ${{ matrix.hostname }} | |
| needs: [prepare_build] | |
| runs-on: ubuntu-latest | |
| timeout-minutes: ${{ github.event.inputs.timeout_minutes || 180 }} # Use input parameter or default to 180 minutes | |
| strategy: | |
| fail-fast: true # Stop all matrix jobs if one fails | |
| matrix: ${{fromJson(needs.prepare_build.outputs.matrix)}} | |
| steps: | |
| - name: Free Disk Space | |
| uses: endersonmenezes/free-disk-space@v3 | |
| with: | |
| remove_android: true | |
| remove_dotnet: true | |
| remove_haskell: true | |
| remove_tool_cache: true | |
| remove_packages: "azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable firefox postgresql* temurin-* *llvm* mysql* dotnet-sdk-*" | |
| remove_packages_one_command: true | |
| remove_folders: "/usr/share/swift /usr/share/miniconda /usr/share/az* /usr/share/glade* /usr/local/lib/node_modules /usr/local/share/chromium /usr/local/share/powershell" | |
| - name: Enable Swap | |
| uses: thejerrybao/setup-swap-space@v1 | |
| with: | |
| swap-space-path: /swapfile | |
| swap-size-gb: 10 | |
| remove-existing-swap-files: true | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Install Nix | |
| uses: DeterminateSystems/nix-installer-action@v22 | |
| with: | |
| extra-conf: ${{ env.EXTRA_NIX_CONFIG }} | |
| - name: Setup Cachix | |
| uses: cachix/cachix-action@v17 | |
| with: | |
| name: rishabh5321 | |
| authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" | |
| - name: Build NixOS configuration | |
| id: build | |
| run: | | |
| set -o pipefail | |
| echo "Starting Nix build for ${{ matrix.hostname }}..." | |
| mkdir -p logs | |
| start_time=$(date +%s) | |
| cachix watch-exec rishabh5321 -- \ | |
| nix build .#nixosConfigurations.${{ matrix.hostname }}.config.system.build.toplevel \ | |
| -L --print-build-logs --out-link result-${{ matrix.hostname }} 2>&1 | tee logs/build_output.log | |
| end_time=$(date +%s) | |
| build_duration=$((end_time - start_time)) | |
| echo "Build duration: $build_duration seconds" | |
| echo "build_duration=$build_duration" >> $GITHUB_OUTPUT | |
| - name: Upload build logs | |
| if: always() | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: build-logs-${{ matrix.hostname }} | |
| path: logs/ | |
| retention-days: 5 | |
| notify_telegram: | |
| name: Send Telegram Notification | |
| runs-on: ubuntu-latest | |
| needs: [build_config] # This job waits for all matrix jobs of build_config | |
| if: always() # Run this job even if some matrix builds failed | |
| steps: | |
| - name: Checkout repository # Needed to access workflow details potentially | |
| uses: actions/checkout@v6 | |
| - name: Determine overall status | |
| id: determine_status | |
| run: | | |
| # Check the outcome of the job it depends on. | |
| # needs.build_config.result will be 'success' only if ALL matrix jobs succeeded. | |
| # If any failed, it will be 'failure'. If skipped, 'skipped'. | |
| STATUS="${{ needs.build_config.result }}" | |
| MESSAGE_STATUS="" | |
| if [[ "$STATUS" == "success" ]]; then | |
| MESSAGE_STATUS="✅ Build successful!" | |
| elif [[ "$STATUS" == "failure" ]]; then | |
| MESSAGE_STATUS="❌ Build failed!" | |
| elif [[ "$STATUS" == "cancelled" ]]; then | |
| MESSAGE_STATUS="🛑 Build cancelled." | |
| else | |
| MESSAGE_STATUS="❓ Build status unknown ($STATUS)." | |
| fi | |
| echo "message_status=$MESSAGE_STATUS" >> "$GITHUB_OUTPUT" | |
| - name: Get branch/PR info | |
| id: get-ref-info | |
| run: | | |
| REF_INFO="" | |
| if [[ "${{ github.event_name }}" == "pull_request" ]]; then | |
| REF_INFO="PR #${{ github.event.pull_request.number }} (${{ github.event.pull_request.head.ref }} -> ${{ github.event.pull_request.base.ref }})" | |
| elif [[ "${{ github.event_name }}" == "push" ]]; then | |
| REF_INFO="Branch: ${{ github.ref_name }}" | |
| elif [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then | |
| REF_INFO="Manual run on branch: ${{ github.ref_name }}" | |
| SPECIFIC_HOST="${{ github.event.inputs.specific_host }}" | |
| if [[ -n "$SPECIFIC_HOST" ]]; then | |
| REF_INFO="$REF_INFO (Specific host: $SPECIFIC_HOST)" | |
| fi | |
| else | |
| REF_INFO="Event: ${{ github.event_name }}" | |
| fi | |
| echo "ref_info=$REF_INFO" >> "$GITHUB_OUTPUT" | |
| - name: Send Telegram Message | |
| uses: appleboy/telegram-action@v1.0.1 # Use a Telegram action | |
| with: | |
| to: ${{ secrets.CHAT_ID }} | |
| token: ${{ secrets.TELEGRAM_TOKEN }} | |
| message: |- | |
| *GitHub Actions Build Status* | |
| Workflow: `${{ github.workflow }}` | |
| Repository: `${{ github.repository }}` | |
| ${{ steps.get-ref-info.outputs.ref_info }} | |
| Commit: `${{ github.sha }}` | |
| *Status:* ${{ steps.determine_status.outputs.message_status }} | |
| View run details: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
| format: markdown # Use markdown formatting for the message | |
| all_builds_passed: | |
| name: All Builds Passed | |
| needs: [build_config] | |
| if: always() | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check build matrix status | |
| run: | | |
| # needs.build_config.result will only be 'success' if all matrix jobs pass | |
| if [[ "${{ needs.build_config.result }}" == "success" ]]; then | |
| echo "All matrix builds passed successfully!" | |
| exit 0 | |
| else | |
| echo "One or more matrix builds failed or were cancelled." | |
| exit 1 | |
| fi |