Loading pkgs/by-name/ni/nixfmt-tree/package.nix +61 −51 Original line number Diff line number Diff line Loading @@ -4,6 +4,8 @@ treefmt, nixfmt-rfc-style, nixfmt-tree, git, writableTmpDirAsHomeHook, settings ? { }, runtimeInputs ? [ ], Loading @@ -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"; Loading Loading @@ -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"; Loading @@ -122,8 +118,19 @@ treefmtWithConfig.overrideAttrs { platforms = lib.platforms.all; }; passthru.tests.simple = runCommand "nixfmt-tree-test-simple" { } '' export XDG_CACHE_HOME=$(mktemp -d) passthru.tests.simple = runCommand "nixfmt-tree-test-simple" { nativeBuildInputs = [ git nixfmt-tree writableTmpDirAsHomeHook ]; } '' git config --global user.email "nix-builder@nixos.org" git config --global user.name "Nix Builder" cat > unformatted.nix <<EOF let to = "be formatted"; in to EOF Loading @@ -138,12 +145,15 @@ treefmtWithConfig.overrideAttrs { mkdir -p repo ( cd repo mkdir .git dir touch .git/index mkdir dir cp ../unformatted.nix a.nix cp ../unformatted.nix dir/b.nix ${lib.getExe nixfmt-tree} dir git init git add . git commit -m "Initial commit" treefmt dir if [[ "$(<dir/b.nix)" != "$(<../formatted.nix)" ]]; then echo "File dir/b.nix was not formatted properly after dir was requested to be formatted" exit 1 Loading @@ -154,7 +164,7 @@ treefmtWithConfig.overrideAttrs { ( cd dir ${lib.getExe nixfmt-tree} treefmt ) if [[ "$(<a.nix)" != "$(<../formatted.nix)" ]]; then Loading Loading
pkgs/by-name/ni/nixfmt-tree/package.nix +61 −51 Original line number Diff line number Diff line Loading @@ -4,6 +4,8 @@ treefmt, nixfmt-rfc-style, nixfmt-tree, git, writableTmpDirAsHomeHook, settings ? { }, runtimeInputs ? [ ], Loading @@ -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"; Loading Loading @@ -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"; Loading @@ -122,8 +118,19 @@ treefmtWithConfig.overrideAttrs { platforms = lib.platforms.all; }; passthru.tests.simple = runCommand "nixfmt-tree-test-simple" { } '' export XDG_CACHE_HOME=$(mktemp -d) passthru.tests.simple = runCommand "nixfmt-tree-test-simple" { nativeBuildInputs = [ git nixfmt-tree writableTmpDirAsHomeHook ]; } '' git config --global user.email "nix-builder@nixos.org" git config --global user.name "Nix Builder" cat > unformatted.nix <<EOF let to = "be formatted"; in to EOF Loading @@ -138,12 +145,15 @@ treefmtWithConfig.overrideAttrs { mkdir -p repo ( cd repo mkdir .git dir touch .git/index mkdir dir cp ../unformatted.nix a.nix cp ../unformatted.nix dir/b.nix ${lib.getExe nixfmt-tree} dir git init git add . git commit -m "Initial commit" treefmt dir if [[ "$(<dir/b.nix)" != "$(<../formatted.nix)" ]]; then echo "File dir/b.nix was not formatted properly after dir was requested to be formatted" exit 1 Loading @@ -154,7 +164,7 @@ treefmtWithConfig.overrideAttrs { ( cd dir ${lib.getExe nixfmt-tree} treefmt ) if [[ "$(<a.nix)" != "$(<../formatted.nix)" ]]; then Loading