Skip to content

Commit b58c681

Browse files
authored
chore: Make nix hook optional (#6431)
This change makes the `nix` pre-commit hook optional in development environments, and enforced only inside Github Actions.
1 parent 404f35d commit b58c681

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

.github/workflows/pre-commit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111
jobs:
1212
# Call the workflow in the XRPLF/actions repo that runs the pre-commit hooks.
1313
run-hooks:
14-
uses: XRPLF/actions/.github/workflows/pre-commit.yml@320be44621ca2a080f05aeb15817c44b84518108
14+
uses: XRPLF/actions/.github/workflows/pre-commit.yml@56de1bdf19639e009639a50b8d17c28ca954f267
1515
with:
1616
runs_on: ubuntu-latest
1717
container: '{ "image": "ghcr.io/xrplf/ci/tools-rippled-pre-commit:sha-41ec7c1" }'

.pre-commit-config.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,15 @@ repos:
6161
hooks:
6262
- id: nix-fmt
6363
name: Format Nix files
64-
entry: nix --extra-experimental-features 'nix-command flakes' fmt
64+
entry: |
65+
bash -c '
66+
if command -v nix &> /dev/null || [ "$GITHUB_ACTIONS" = "true" ]; then
67+
nix --extra-experimental-features "nix-command flakes" fmt "$@"
68+
else
69+
echo "Skipping nix-fmt: nix not installed and not in GitHub Actions"
70+
exit 0
71+
fi
72+
' --
6573
language: system
6674
types:
6775
- nix

0 commit comments

Comments
 (0)