summaryrefslogtreecommitdiff
path: root/flake.nix
diff options
context:
space:
mode:
authorThomas Mühlbacher <tmuehlbacher@posteo.net>2024-05-27 17:04:24 +0200
committerKent Overstreet <kent.overstreet@linux.dev>2024-05-27 19:30:26 -0400
commitce01c61ba5e7f272b5d18ae5a46f108dd569c0f4 (patch)
tree0a3626c89fe72934e691a71747afc6ec45c765cf /flake.nix
parent0e414b462f97c29b79e92318c48073adeba59675 (diff)
build(nix): enable rustfmt check+formatter
with this, the gh actions ci will fail if submitted code does not adhere to rustfmt rules. additionally, running `nix fmt` will also format rust code. because we want rules only supported by nightly rustfmt, and nixpkgs doesn't have a nightly toolchain, we need to pull in another flake input: fenix.
Diffstat (limited to 'flake.nix')
-rw-r--r--flake.nix13
1 files changed, 13 insertions, 0 deletions
diff --git a/flake.nix b/flake.nix
index 111f7d7f..6d946dbc 100644
--- a/flake.nix
+++ b/flake.nix
@@ -11,6 +11,11 @@
inputs.nixpkgs.follows = "nixpkgs";
};
+ fenix = {
+ url = "github:nix-community/fenix";
+ inputs.nixpkgs.follows = "nixpkgs";
+ };
+
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
@@ -23,6 +28,7 @@
nixpkgs,
flake-parts,
treefmt-nix,
+ fenix,
flake-compat,
...
}:
@@ -41,8 +47,12 @@
self',
config,
pkgs,
+ system,
...
}:
+ let
+ rustfmtToml = builtins.fromTOML (builtins.readFile ./rustfmt.toml);
+ in
{
packages.default = config.packages.bcachefs-tools;
packages.bcachefs-tools = pkgs.callPackage ./build.nix { };
@@ -74,6 +84,9 @@
programs = {
nixfmt-rfc-style.enable = true;
+ rustfmt.edition = rustfmtToml.edition;
+ rustfmt.enable = true;
+ rustfmt.package = fenix.packages.${system}.default.rustfmt;
};
};
};