From f96187f20f0a4158b8ee0d0f0bc1315c455f57b8 Mon Sep 17 00:00:00 2001 From: Simon Rainerson Date: Tue, 13 Feb 2024 10:02:24 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Make=20checks.nixfmt=20work=20fr?= =?UTF-8?q?om=20everywhere?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If $nixFiles were expressed as relative to the root of the project, nixfmt would fail when ran from a sub directory. Now cd to the root first which will work for both relative and absolute paths. Since nix (and thus we) have not committed to using flakes this instead uses git to find the root of the project. --- CHANGELOG.md | 3 +++ ci/nixfmt | 2 ++ 2 files changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b8f605..6979961 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed +- `.#checks.nixfmt` can be run from everywhere when nixFiles are relative to project. + ## [10.0.0] - 2024-02-06 ### Added diff --git a/ci/nixfmt b/ci/nixfmt index 70490a2..f6f28bc 100644 --- a/ci/nixfmt +++ b/ci/nixfmt @@ -13,6 +13,8 @@ if [[ $* =~ (^|[[:space:]])+--fix([[:space:]]|$)+ ]]; then check="" fi +cd "$(git rev-parse --show-toplevel)" + if [ $# -eq 0 ] || [ -z "$check" ]; then exitCode=0 files=()