name: "Build Nixpkgs manual v2"

on:
  pull_request_target:
    branches:
      - master
    paths:
      - 'doc/**'
      - 'lib/**'
      - 'pkgs/tools/nix/nixdoc/**'

permissions: {}

jobs:
  nixpkgs:
    name: nixpkgs-manual-build
    runs-on: ubuntu-24.04
    steps:
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
        with:
          ref: refs/pull/${{ github.event.pull_request.number }}/merge

      - uses: cachix/install-nix-action@d1ca217b388ee87b2507a9a93bf01368bde7cec2 # v31
        with:
          extra_nix_config: sandbox = true

      - uses: cachix/cachix-action@0fc020193b5a1fa3ac4575aa3a7d3aa6a35435ad # v16
        if: github.repository_owner == 'NixOS'
        with:
          # This cache is for the nixpkgs repo checks and should not be trusted or used elsewhere.
          name: nixpkgs-ci
          authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'

      - name: Building Nixpkgs manual
        run: NIX_PATH=nixpkgs=$(pwd) nix-build --option restrict-eval true pkgs/top-level/release.nix -A manual -A manual.tests
