name: "Building Nixpkgs lib-tests"

on:
  pull_request_target:
    paths:
      - 'lib/**'
      - 'maintainers/**'

permissions: {}

jobs:
  get-merge-commit:
    uses: ./.github/workflows/get-merge-commit.yml

  nixpkgs-lib-tests:
    name: nixpkgs-lib-tests
    runs-on: ubuntu-24.04
    needs: get-merge-commit
    if: needs.get-merge-commit.outputs.mergedSha
    steps:
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
        with:
          ref: ${{ needs.get-merge-commit.outputs.mergedSha }}

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

      - name: Building Nixpkgs lib-tests
        run: |
          nix-build --arg pkgs "(import ./ci/. {}).pkgs" ./lib/tests/release.nix
