diff --git a/devShell.nix b/devShell.nix index 45c4bb6..919e2d5 100644 --- a/devShell.nix +++ b/devShell.nix @@ -67,6 +67,7 @@ devshell.mkShell { name = "digga"; packages = with pkgs; [ fd + treefmt alejandra # Use the latest stable version of nix unstablePkgs.nix @@ -105,8 +106,8 @@ devshell.mkShell { }) (utils { name = "fmt"; - help = "Check Nix formatting"; - command = "alejandra \${@} $PRJ_ROOT"; + help = "Check formatting"; + command = "treefmt \${@} $PRJ_ROOT"; }) (utils { name = "evalnix"; diff --git a/examples/devos/profiles/core/common.nix b/examples/devos/profiles/core/common.nix index beed6bc..9cfca96 100644 --- a/examples/devos/profiles/core/common.nix +++ b/examples/devos/profiles/core/common.nix @@ -13,8 +13,7 @@ in # Selection of sysadmin tools that can come in handy systemPackages = with pkgs; [ - # TODO: must come from unstable channel - # alejandra + alejandra binutils coreutils curl diff --git a/examples/devos/shell/devos.nix b/examples/devos/shell/devos.nix index ea08f0f..5f4e8e8 100644 --- a/examples/devos/shell/devos.nix +++ b/examples/devos/shell/devos.nix @@ -35,7 +35,7 @@ in help = nvfetcher-bin.meta.description; command = "cd $PRJ_ROOT/pkgs; ${nvfetcher-bin}/bin/nvfetcher -c ./sources.toml $@"; } - (linter alejandra) + (linter treefmt) (linter editorconfig-checker) (docs mdbook) diff --git a/examples/devos/shell/hooks/pre-commit.sh b/examples/devos/shell/hooks/pre-commit.sh index 454289b..4ce4fa1 100755 --- a/examples/devos/shell/hooks/pre-commit.sh +++ b/examples/devos/shell/hooks/pre-commit.sh @@ -9,13 +9,12 @@ fi diff="git diff-index --name-only --cached $against --diff-filter d" -nix_files=($($diff -- '*.nix')) all_files=($($diff)) -# Format staged nix files. -if ((${#nix_files[@]} != 0)); then - alejandra "${nix_files[@]}" && - git add "${nix_files[@]}" +# Format staged files. +if ((${#all_files[@]} != 0)); then + treefmt "${all_files[@]}" && + git add "${all_files[@]}" fi # check editorconfig diff --git a/examples/devos/treefmt.toml b/examples/devos/treefmt.toml new file mode 100644 index 0000000..fe5d1f3 --- /dev/null +++ b/examples/devos/treefmt.toml @@ -0,0 +1,3 @@ +[formatter.nix] +command = "alejandra" +includes = ["*.nix"] diff --git a/flake.nix b/flake.nix index 8ba130a..93e6130 100644 --- a/flake.nix +++ b/flake.nix @@ -144,7 +144,8 @@ ''; # digga-local use - formatter = nixlib.lib.genAttrs supportedSystems (s: nixpkgs.legacyPackages.${s}.alejandra); + ## This doesn't appear to be used? + formatter = nixlib.lib.genAttrs supportedSystems (s: nixpkgs.legacyPackages.${s}.treefmt); # system-space and pass sytem and input to each file jobs = polyfillOutput ./jobs; checks = polyfillOutput ./checks; diff --git a/treefmt.toml b/treefmt.toml new file mode 100644 index 0000000..fe5d1f3 --- /dev/null +++ b/treefmt.toml @@ -0,0 +1,3 @@ +[formatter.nix] +command = "alejandra" +includes = ["*.nix"]