From b41229ca07af04e310b70fba24ec99f1cafc3913 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Thu, 15 May 2025 13:18:19 +0300 Subject: [PATCH] build(Cargo.toml): set minimum supported Rust version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sets the MSRV for the crate. The `rust-toolchain.toml` file is dropped since this is too retrictive when choosing choosing a toolchain for developing the crate – uses exact semantics. It is necessary to change the `flake.nix` to read this version from the `Cargo.toml` so that it can select the rust toolchain to use via `rust-overlay`. Signed-off-by: Lars Wirzenius Co-authored-by: Fintan Halpenny --- Cargo.toml | 3 +++ flake.lock | 18 +++++++++--------- flake.nix | 6 +++++- rust-toolchain.toml | 4 ---- 4 files changed, 17 insertions(+), 14 deletions(-) delete mode 100644 rust-toolchain.toml diff --git a/Cargo.toml b/Cargo.toml index 1f35143..71059fc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,6 +5,9 @@ license = "MIT OR Apache-2.0" version = "0.1.0" authors = ["Fintan Halpenny "] edition = "2021" +# N.B. always use the full semver so that rust-overlay in `flake.nix` can select +# the correct version +rust-version = "1.82.0" [dependencies] indexmap = { version = "2.7.1", features = ["serde"] } diff --git a/flake.lock b/flake.lock index 45f8812..eea34c9 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "crane": { "locked": { - "lastModified": 1742394900, - "narHash": "sha256-vVOAp9ahvnU+fQoKd4SEXB2JG2wbENkpqcwlkIXgUC0=", + "lastModified": 1747260204, + "narHash": "sha256-KUb6MFWc2DYeTCmcEkrBrrqhxAgO6NHZh5qQKwsjG6I=", "owner": "ipetkov", "repo": "crane", - "rev": "70947c1908108c0c551ddfd73d4f750ff2ea67cd", + "rev": "7f85510df37247c86a0c44032f49aa18292ee11f", "type": "github" }, "original": { @@ -35,11 +35,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1742998488, - "narHash": "sha256-r7dqSLNkzg1rOPsq4Tuc6p+UtAGqNRMma4riupsuZv4=", + "lastModified": 1747308931, + "narHash": "sha256-aFP8PqwBbokBQ6IKpD71RbhSWV4qjyg6M0y62rodRts=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "8e0b1e9c8c4dfaef0ff85e09c91294ba4afa4168", + "rev": "ed8ec80540abb9a7e69da65916cf3d0b26174555", "type": "github" }, "original": { @@ -64,11 +64,11 @@ ] }, "locked": { - "lastModified": 1742956365, - "narHash": "sha256-Slrqmt6kJ/M7Z/ce4ebQWsz2aeEodrX56CsupOEPoz0=", + "lastModified": 1747190175, + "narHash": "sha256-s33mQ2s5L/2nyllhRTywgECNZyCqyF4MJeM3vG/GaRo=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "a0e3395c63cdbc9c1ec17915f8328c077c79c4a1", + "rev": "58160be7abad81f6f8cb53120d5b88c16e01c06d", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 72c50bc..ba7578d 100644 --- a/flake.nix +++ b/flake.nix @@ -29,7 +29,10 @@ overlays = [(import rust-overlay)]; }; - rustToolChain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; + # Get the `rust-version` from the Cargo manifest + manifest = builtins.fromTOML (builtins.readFile ./Cargo.toml); + rust-version = manifest.package.rust-version; + rustToolChain = pkgs.rust-bin.stable.${rust-version}.default; craneLib = (crane.mkLib pkgs).overrideToolchain rustToolChain; src = lib.cleanSourceWith { @@ -99,6 +102,7 @@ # Extra inputs can be added here; cargo and rustc are provided by default # from the toolchain that was specified earlier. packages = with pkgs; [ + cargo-nextest cargo-watch ripgrep rust-analyzer diff --git a/rust-toolchain.toml b/rust-toolchain.toml deleted file mode 100644 index ba99c25..0000000 --- a/rust-toolchain.toml +++ /dev/null @@ -1,4 +0,0 @@ -[toolchain] -channel = "1.84" -profile = "default" -components = [ "rust-src" ]