Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/check-flake.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Check Nix flake
on:
pull_request_target:
pull_request:
Copy link
Contributor Author

@RyanPrussin RyanPrussin Aug 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The purpose of this change is to fix the automated Nix CI workflow for the nix flake check command.

The Problem

The old workflow used pull_request_target, which caused it to run checks against the outdated flake.lock file from the main branch, leading to consistent failures due to the constraints of this workflow (which requires the tested branch to have a flake.lock file generated in the last 30 days).

image

See image source here

The Solution

This change switches the workflow to the pull_request trigger, which correctly runs checks against the flake.lock being added in a pull request branch rather than against the flake.lock in the main branch.

Why It's Still Failing

Because the workflow specifications are read from the main branch, the new pull_request trigger will not take effect until this change is merged. The checks will continue to fail until then, and as a result you will likely have to override the checks to deploy this.

paths:
- '*.nix'
- '**.nix'
Copy link
Contributor Author

@RyanPrussin RyanPrussin Aug 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The purpose of this change is to ensure that this CI check is triggered in all cases it is required, i.e. whenever any changes are made to any files in the project that have a .nix file extension.

The Problem

'*.nix' only grabs Nix files in the project root directory, e.g. flake.nix. This means this check won't get triggered if a PR has changes applied to .nix files elsewhere in the project, such as in the nix directory. This effectively means files outside of the root directory like nix/shell-plugins.nix can be changed without this workflow being triggered.

The Solution

'**.nix' is the format recommended by GitHub's docs; it should ensure that this GitHub workflow will trigger on changes to any Nix files in any directories in the project, avoiding situations where checks should have been run but were not.

- flake.lock
push:
branches:
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/update-flake-dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@ jobs:
- uses: DeterminateSystems/magic-nix-cache-action@main
- name: update flake.lock
run: nix flake update
- name: Define Unique COMMIT_BRANCH by Timestamp
run: |
TIMESTAMP=$(date +'%Y-%m-%d-%H%M%S')
echo "COMMIT_BRANCH=automation/update-flake-dependencies-$TIMESTAMP" >> $GITHUB_ENV
- name: Create signed commit with flake.lock changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FILE_TO_COMMIT: flake.lock
COMMIT_BRANCH: automation/update-flake-dependencies
Copy link
Contributor Author

@RyanPrussin RyanPrussin Aug 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The purpose of this change is to fix the broken weekly Update flake dependencies GitHub workflow.

The Problem

Once a week and on manual workflow executions, the same branch name automation/update-flake-dependencies is being created even though it is never being updated or cleaned up, which causes it to fail on on each subsequent run of this GitHub Action.
image
See full error log from screenshot here.

The Solution

Add a timestamp to the end of the branch name so it is unique. This means that a new branch + PR will be created on every run of this workflow.

Copy link
Contributor Author

@RyanPrussin RyanPrussin Aug 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: the reason I made a separate branch was under the assumption that if a new branch and PR is created every week, it will notify the 2nd reviewer more frequently and may result in more of the PRs getting the 2nd approvals they need, but obviously it's more of a spammy solution.

COMMIT_MESSAGE: "chore(nix): Update Flake dependencies"
run: |
# make sure something actually changed first, if not, no updates required
Expand Down
12 changes: 6 additions & 6 deletions flake.lock
Copy link
Contributor Author

@RyanPrussin RyanPrussin Aug 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normally I would not have updated the lock file in the same PR as CI changes, but your entire CI pipeline for Nix is not working as expected and that is partially because it is dependent on an up-to-date flake.lock file generated within the last 30 days in order to pass checks. See The Problem in this comment for more details.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading