1
1
mirror of https://github.com/divnix/digga.git synced 2024-07-15 02:40:30 +03:00

🧠 redesign Use treefmt

This commit is contained in:
Lord-Valen 2022-11-06 21:27:52 -05:00 committed by David Arnold
parent 6c72c7ac8b
commit 68dd6bd83b
7 changed files with 17 additions and 11 deletions

View File

@ -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";

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -0,0 +1,3 @@
[formatter.nix]
command = "alejandra"
includes = ["*.nix"]

View File

@ -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;

3
treefmt.toml Normal file
View File

@ -0,0 +1,3 @@
[formatter.nix]
command = "alejandra"
includes = ["*.nix"]