Skip to content

Commit

Permalink
fix: unset $PRJ_ROOT before running the repo's treefmt locally with t…
Browse files Browse the repository at this point in the history
…reefmt-nix

`numtide/devshell` sets $PRJ_ROOT, which is used to default `--tree-root`. This conflicts with `--tree-root-file` being set by `treefmt-nix`.

Signed-off-by: Brian McGee <[email protected]>
  • Loading branch information
brianmcgee committed Aug 1, 2024
1 parent e304d7a commit e384466
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions nix/devshell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ perSystem.devshell.mkShell {

commands = [
{package = perSystem.gomod2nix.default;}
# This custom command is needed to prevent a conflict between --tree-root and --tree-root-file.
# treefmt-nix sets --tree-root-file whilst treefmt defaults --tree-root from $PRJ_ROOT, which is set by numtide/devshell.
{
name = "fmt";
help = "runs `nix fmt` but unsets $PRJ_ROOT first";
package = pkgs.writeShellScriptBin "fmt" ''
unset PRJ_ROOT
nix fmt -- "$@"
'';
}
{
name = "docs:dev";
help = "serve docs for local development";
Expand Down

0 comments on commit e384466

Please sign in to comment.