summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Mühlbacher <tmuehlbacher@posteo.net>2024-05-22 21:35:41 +0200
committerThomas Mühlbacher <tmuehlbacher@posteo.net>2024-05-22 22:35:05 +0200
commit2e316499df35053c140ee46819185da8b6fa9d4b (patch)
tree08174610ee2dd731364175f1865f16485243952e
parentcc16402e4f31a63ab415043da06f0445fe55765c (diff)
build(nix): add treefmt-nix
currently still bare but can be extended with a number of different formatters (rustfmt, clang-format, ...). For full list see https://flake.parts/options/treefmt-nix Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
-rw-r--r--flake.lock23
-rw-r--r--flake.nix23
2 files changed, 42 insertions, 4 deletions
diff --git a/flake.lock b/flake.lock
index 2b883b6e..58b8eeb5 100644
--- a/flake.lock
+++ b/flake.lock
@@ -66,7 +66,28 @@
"inputs": {
"flake-compat": "flake-compat",
"flake-parts": "flake-parts",
- "nixpkgs": "nixpkgs"
+ "nixpkgs": "nixpkgs",
+ "treefmt-nix": "treefmt-nix"
+ }
+ },
+ "treefmt-nix": {
+ "inputs": {
+ "nixpkgs": [
+ "nixpkgs"
+ ]
+ },
+ "locked": {
+ "lastModified": 1715940852,
+ "narHash": "sha256-wJqHMg/K6X3JGAE9YLM0LsuKrKb4XiBeVaoeMNlReZg=",
+ "owner": "numtide",
+ "repo": "treefmt-nix",
+ "rev": "2fba33a182602b9d49f0b2440513e5ee091d838b",
+ "type": "github"
+ },
+ "original": {
+ "owner": "numtide",
+ "repo": "treefmt-nix",
+ "type": "github"
}
}
},
diff --git a/flake.nix b/flake.nix
index 4a2d3c4c..1070466e 100644
--- a/flake.nix
+++ b/flake.nix
@@ -6,6 +6,11 @@
flake-parts.url = "github:hercules-ci/flake-parts";
+ treefmt-nix = {
+ url = "github:numtide/treefmt-nix";
+ inputs.nixpkgs.follows = "nixpkgs";
+ };
+
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
@@ -17,10 +22,13 @@
self,
nixpkgs,
flake-parts,
+ treefmt-nix,
flake-compat,
...
}:
flake-parts.lib.mkFlake { inherit inputs; } {
+ imports = [ inputs.treefmt-nix.flakeModule ];
+
# can be extended, but these have proper binary cache support in nixpkgs
# as of writing.
systems = [
@@ -41,13 +49,22 @@
packages.bcachefs-tools-fuse = config.packages.bcachefs-tools.override { fuseSupport = true; };
- formatter = pkgs.nixfmt-rfc-style;
-
devShells.default = pkgs.mkShell {
- inputsFrom = [ config.packages.default ];
+ inputsFrom = [
+ config.packages.default
+ config.treefmt.build.devShell
+ ];
LIBCLANG_PATH = "${pkgs.clang.cc.lib}/lib";
};
+
+ treefmt.config = {
+ projectRootFile = "flake.nix";
+
+ programs = {
+ nixfmt-rfc-style.enable = true;
+ };
+ };
};
};
}