name: Dependency updates on: schedule: - cron: "0 6 * * 1" workflow_dispatch: inputs: force_nixpkgs: description: "Update nixpkgs even when no watched package version changed" type: boolean default: false permissions: contents: write pull-requests: write concurrency: group: dependency-updates cancel-in-progress: false jobs: update-dependencies: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v6 - name: Install Nix uses: DeterminateSystems/nix-installer-action@v22 - name: Decide whether nixpkgs should be updated id: nixpkgs_gate run: | set -euo pipefail scripts/check-nixpkgs-relevance.sh >> "$GITHUB_OUTPUT" - name: Update flake inputs run: | set -euo pipefail if [[ "${{ steps.nixpkgs_gate.outputs.should_update_nixpkgs }}" == "true" || "${{ inputs.force_nixpkgs }}" == "true" ]]; then nix flake update nixpkgs else echo "Skipping nixpkgs update: watched package versions on nixos-unstable are unchanged." fi nix flake update zapret - name: Update pinned sources env: GITHUB_TOKEN: ${{ github.token }} run: | set -euo pipefail scripts/update-pins.sh --self-test scripts/update-pins.sh | tee "$RUNNER_TEMP/pin-updates.txt" # A nixpkgs bump can bring a nixfmt whose style differs; restyle the tree with # it so the nix-format check passes and the restyle rides along in the PR. - name: Reformat Nix files run: nix fmt - name: Detect dependency file changes id: changes run: | set -euo pipefail if git diff --quiet -- flake.lock pkgs; then echo "has_changes=false" >> "$GITHUB_OUTPUT" else echo "has_changes=true" >> "$GITHUB_OUTPUT" fi - name: Build updated packages if: steps.changes.outputs.has_changes == 'true' run: | set -euo pipefail mapfile -t attrs < <(scripts/update-pins.sh --attrs) nix build --no-link "${attrs[@]}" - name: Run flake checks if: steps.changes.outputs.has_changes == 'true' run: nix flake check --print-build-logs - name: Compose pull request body if: steps.changes.outputs.has_changes == 'true' run: | set -euo pipefail { echo "## Automated dependency update" echo echo "Managed by CI; the \`ci/update-dependencies\` branch is reused across runs." echo echo "### Pinned sources" if [[ -s "$RUNNER_TEMP/pin-updates.txt" ]]; then sed 's/^/- /' "$RUNNER_TEMP/pin-updates.txt" else echo "- no pin changes" fi echo echo "### Flake inputs" echo "- nixpkgs updated: \`${{ steps.nixpkgs_gate.outputs.should_update_nixpkgs }}\`" echo "- changed watched attrs: \`${{ steps.nixpkgs_gate.outputs.nixpkgs_changed_watch_attrs }}\`" echo "- zapret: refreshed every run" echo echo '```' git diff --stat echo '```' } > "$RUNNER_TEMP/pr-body.md" cat "$RUNNER_TEMP/pr-body.md" >> "$GITHUB_STEP_SUMMARY" - name: Create or update pull request if: steps.changes.outputs.has_changes == 'true' uses: peter-evans/create-pull-request@v8 with: branch: ci/update-dependencies delete-branch: false add-paths: | flake.lock pkgs *.nix commit-message: "chore(deps): refresh flake inputs and pinned sources" title: "chore(deps): refresh flake inputs and pinned sources" body-path: ${{ runner.temp }}/pr-body.md labels: | dependencies nix - name: No dependency changes if: steps.changes.outputs.has_changes != 'true' run: echo "No dependency updates detected."