From 3bf9a1957159313d6f10aa08aed3863b0514ad43 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20M=C3=BChlbacher?= <tmuehlbacher@posteo.net>
Date: Fri, 21 Mar 2025 16:34:02 +0000
Subject: [PATCH] feat(nix): add an MSRV build to CI

Having a build that uses the actual version of Rust specified in
Cargo.toml should allow us to catch issues with breaking MSRV compat
more easily.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
---
 Cargo.toml |  2 +-
 flake.nix  | 16 ++++++++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/Cargo.toml b/Cargo.toml
index d1a92ab7..54b6ec35 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -3,7 +3,7 @@ name = "bcachefs-tools"
 version = "1.25.0"
 authors = ["Yuxuan Shui <yshuiv7@gmail.com>", "Kayla Firestack <dev@kaylafire.me>", "Kent Overstreet <kent.overstreet@linux.dev>" ]
 edition = "2021"
-rust-version = "1.77"
+rust-version = "1.77.0"
 
 [[bin]]
 name = "bcachefs"
diff --git a/flake.nix b/flake.nix
index ce6f4084..c8225203 100644
--- a/flake.nix
+++ b/flake.nix
@@ -253,6 +253,22 @@
             }
           );
 
+          # cargo clippy with the current minimum supported rust version
+          # according to Cargo.toml
+          checks.msrv =
+            let
+              rustVersion = cargoToml.package.rust-version;
+              common = pkgs.callPackage mkCommon { inherit crane rustVersion; };
+            in
+            common.craneLib.cargoClippy (
+              common.args
+              // {
+                pname = "msrv";
+                inherit (common) cargoArtifacts;
+                cargoClippyExtraArgs = "--all-targets --all-features -- --deny warnings";
+              }
+            );
+
           devShells.default = pkgs.mkShell {
             inputsFrom = [
               config.packages.default