on:
  push:
jobs:
  check:
    runs-on: nixos
    steps:
      - uses: "https://git.salame.cl/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683" # v4
      - name: Run checks
        run: |
          nix --version
          nix-fast-build --max-jobs 2 --no-nom --skip-cached --no-link \
            --flake ".#checks.$(nix eval --raw --impure --expr builtins.currentSystem)"
  check-renovaterc:
    runs-on: nixos
    steps:
      - uses: "https://git.salame.cl/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683" # v4
      - name: Validate renovaterc.json
        run: |
          nix --version
          nix shell nixpkgs#renovate --command renovate-config-validator
  build-packages:
    runs-on: nixos
    needs: check
    steps:
      - uses: "https://git.salame.cl/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683" # v4
      - name: Build target
        run: |
          nix --version
          nix-fast-build --max-jobs 2 --no-nom --skip-cached --no-link \
            --flake ".#packages.$(nix eval --raw --impure --expr builtins.currentSystem)"
  build-vm:
    runs-on: nixos
    needs: build-packages
    steps:
      - uses: "https://git.salame.cl/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683" # v4
      - name: Build VM configuration
        run: |
          nix --version
          nix build --print-build-logs '.#nixosConfigurations.vm.config.system.build.toplevel'
  report-size:
    runs-on: nixos
    needs:
      - build-packages
      - build-vm
    steps:
      - uses: "https://git.salame.cl/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683" # v4
      - run: nix --version
      - name: Create Size Report
        uses: "https://git.salame.cl/jalil/nix-flake-outputs-size@5c40a31e3e2ed0ea28f8ba68deca41d05fdf2e71" # main
        with:
          # Create a comment on the associated PR
          comment-on-pr: ${{ github.ref_name != 'main' }}
          # Generate artifacts on main (to speed up comparisons)
          generate-artifact: ${{ github.ref_name == 'main' }}
          # Generate comparisons to main
          do-comparison: 'true'
          # This job's name (so we can find the artifacts)
          job-name: report-size