Skip to content

Commit fecaa0a

Browse files
committed
chore: add treefmt config for nix files
* add a ci job that run `treefmt` * make it `nix fmt` default formatter * add dumb simple `pre-commit` and `editorconfig`
1 parent 48bdb73 commit fecaa0a

File tree

6 files changed

+46
-1
lines changed

6 files changed

+46
-1
lines changed

.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# EditorConfig is awesome: https://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
[*.nix]
7+
indent_style = space
8+
indent_size = 2
9+
end_of_line = lf
10+
charset = utf-8
11+
trim_trailing_whitespace = true
12+
insert_final_newline = true

.github/workflows/treefmt.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: treefmt
2+
on:
3+
pull_request:
4+
push:
5+
branches: develop
6+
jobs:
7+
formatter:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
- uses: cachix/install-nix-action@v31
12+
with:
13+
nix_path: nixpkgs=channel:nixos-unstable
14+
- name: treefmt
15+
run: nix-shell -p treefmt nixpkgs-fmt --run "treefmt --ci"

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ __pycache__/
1717
result*
1818
.env-local
1919
.history
20-
20+
.envrc
2121

2222
#IDE
2323
.idea/

.pre-commit-config.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
repos:
2+
- repo: local
3+
hooks:
4+
- id: treefmt
5+
name: treefmt
6+
entry: treefmt
7+
language: system
8+
types: [file]

flake.nix

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1413,6 +1413,8 @@
14131413
trigger-nix-build = mkApp "trigger-nix-build" "trigger-nix-build";
14141414
};
14151415

1416+
formatter = pkgs.treefmt;
1417+
14161418
# 'devShells.default' lists the set of packages that are included in the
14171419
# ambient $PATH environment when you run 'nix develop'. This is useful
14181420
# for development and puts many convenient devtools instantly within
@@ -1456,7 +1458,10 @@
14561458
basePackages.run-testinfra
14571459
basePackages.cleanup-ami
14581460
dbmate
1461+
formatter # treefmt
1462+
nixpkgs-fmt
14591463
nushell
1464+
pre-commit
14601465
pythonEnv
14611466
nix-fast-build
14621467
];

treefmt.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# One CLI to format the code tree - https://github.com/numtide/treefmt
2+
3+
[formatter.nix]
4+
command = "nixpkgs-fmt"
5+
includes = ["*.nix"]

0 commit comments

Comments
 (0)