Skip to content

Commit

Permalink
Merge pull request #1379 from Mic92/merge-when-green-joerg
Browse files Browse the repository at this point in the history
nix-fmt: fix treefmt
  • Loading branch information
Mic92 authored Nov 2, 2024
2 parents a096dee + 6c7e29f commit b8db102
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 23 deletions.
28 changes: 7 additions & 21 deletions flake.lock

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

1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
nix-index-database.inputs.nixpkgs.follows = "nixpkgs";

nix.url = "github:Mic92/nix-1";
nix.inputs.nixpkgs.follows = "nixpkgs";
nix.inputs.flake-parts.follows = "";
nix.inputs.nixpkgs-regression.follows = "";
nix.inputs.git-hooks-nix.follows = "";
Expand Down
13 changes: 11 additions & 2 deletions home/.zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ nix-fmt() {
toplevel=$(command git rev-parse --show-toplevel)
buildArgs=()
fmt="$toplevel/.git/nix-fmt"
if [[ ! -f "$toplevel/.git/nix-fmt/bin/treefmt" ]]; then
if [[ ! -d "$toplevel/.git/nix-fmt" ]]; then
needsUpdate=1
elif [[ -n "$toplevel" ]]; then
buildArgs+=("-o" "$toplevel"/.git/nix-fmt)
Expand All @@ -442,8 +442,17 @@ nix-fmt() {
if [[ "$needsUpdate" == 1 ]]; then
fmt=$(command nix build --builders '' "${buildArgs[@]}" ".#formatter.${currentSystem}" --print-out-paths)
fi
ln -sf "$fmt" "$toplevel/.git/nix-fmt"

"$fmt/bin/"*
# treefmt has multiple outputs
if [[ -x "$fmt/bin/treefmt" ]]; then
"$fmt/bin/treefmt" "$@"
return
fi
for file in "$fmt/bin/"*; do
"$file" "$@"
return
done
}

nix-call-package() {
Expand Down

0 comments on commit b8db102

Please sign in to comment.