From a371ed99e11d8afe5c144a5182af04120ed65a61 Mon Sep 17 00:00:00 2001 From: Matt Sturgeon Date: Fri, 16 May 2025 18:38:29 +0100 Subject: [PATCH] nixfmt-tree: remove `tree-root-file` default This isn't needed since treefmt 2.3.1, as it can now determine the tree root by asking `git`. --- pkgs/by-name/ni/nixfmt-tree/package.nix | 98 ++++++++++++++----------- 1 file changed, 54 insertions(+), 44 deletions(-) diff --git a/pkgs/by-name/ni/nixfmt-tree/package.nix b/pkgs/by-name/ni/nixfmt-tree/package.nix index f9a7991544ef..a36a449b3449 100644 --- a/pkgs/by-name/ni/nixfmt-tree/package.nix +++ b/pkgs/by-name/ni/nixfmt-tree/package.nix @@ -4,6 +4,8 @@ treefmt, nixfmt-rfc-style, nixfmt-tree, + git, + writableTmpDirAsHomeHook, settings ? { }, runtimeInputs ? [ ], @@ -30,9 +32,6 @@ let # The default is warn, which would be too annoying for people who just care about Nix on-unmatched = lib.mkOptionDefault "info"; - # Assume the tree is a Git repository, will fail if it's not - tree-root-file = lib.mkOptionDefault ".git/index"; - # NOTE: The `mkIf` condition should not be needed once `runtimePackages` is removed. formatter.nixfmt = lib.mkIf (lib.any isNixfmt allRuntimeInputs) { command = "nixfmt"; @@ -102,9 +101,6 @@ treefmtWithConfig.overrideAttrs { # Log level for files treefmt won't format on-unmatched = "info"; - # Assume the tree is a Git repository, will fail if it's not - tree-root-file = ".git/index"; - # Configure nixfmt for .nix files formatter.nixfmt = { command = "nixfmt"; @@ -122,49 +118,63 @@ treefmtWithConfig.overrideAttrs { platforms = lib.platforms.all; }; - passthru.tests.simple = runCommand "nixfmt-tree-test-simple" { } '' - export XDG_CACHE_HOME=$(mktemp -d) - cat > unformatted.nix < formatted.nix < unformatted.nix < formatted.nix <