diff options
author | Thomas Mühlbacher <tmuehlbacher@posteo.net> | 2024-05-27 17:04:24 +0200 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-05-27 19:30:26 -0400 |
commit | ce01c61ba5e7f272b5d18ae5a46f108dd569c0f4 (patch) | |
tree | 0a3626c89fe72934e691a71747afc6ec45c765cf /flake.nix | |
parent | 0e414b462f97c29b79e92318c48073adeba59675 (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.nix | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -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; }; }; }; |