We're going to use rust-overlay for setting up an MSRV build.
---
flake.lock | 46 ++++++++++++++--------------------------------
flake.nix | 18 ++++++++++++------
2 files changed, 26 insertions(+), 38 deletions(-)
diff --git a/flake.lock b/flake.lock
index b38af96b..189ea88a 100644
--- a/flake.lock
+++ b/flake.lock
@@ -15,27 +15,6 @@
"type": "github"
}
},
- "fenix": {
- "inputs": {
- "nixpkgs": [
- "nixpkgs"
- ],
- "rust-analyzer-src": "rust-analyzer-src"
- },
- "locked": {
- "lastModified": 1736318091,
- "narHash": "sha256-RkRHXZaMgOMGgkW2YmEqxxDDYRiGFbfr1JuaI0VrCKo=",
- "owner": "nix-community",
- "repo": "fenix",
- "rev": "9e13860d50cbfd42e79101a516e1939c7723f093",
- "type": "github"
- },
- "original": {
- "owner": "nix-community",
- "repo": "fenix",
- "type": "github"
- }
- },
"flake-compat": {
"flake": false,
"locked": {
@@ -101,27 +80,30 @@
"root": {
"inputs": {
"crane": "crane",
- "fenix": "fenix",
"flake-compat": "flake-compat",
"flake-parts": "flake-parts",
"nixpkgs": "nixpkgs",
+ "rust-overlay": "rust-overlay",
"treefmt-nix": "treefmt-nix"
}
},
- "rust-analyzer-src": {
- "flake": false,
+ "rust-overlay": {
+ "inputs": {
+ "nixpkgs": [
+ "nixpkgs"
+ ]
+ },
"locked": {
- "lastModified": 1736266405,
- "narHash": "sha256-V2FDSb8YjuquZduBRNp5niWYlWurja2yGN6Xzh5GPYk=",
- "owner": "rust-lang",
- "repo": "rust-analyzer",
- "rev": "91fc0a239af4e56b84b1d3974ac0f34dcc99b895",
+ "lastModified": 1736438724,
+ "narHash": "sha256-m0CFbWVKtXsAr5OBgWNwR8Uam/jkPIjWgJkdH9DY46M=",
+ "owner": "oxalica",
+ "repo": "rust-overlay",
+ "rev": "15897cf5835bb95aa002b42c22dc61079c28f7c8",
"type": "github"
},
"original": {
- "owner": "rust-lang",
- "ref": "nightly",
- "repo": "rust-analyzer",
+ "owner": "oxalica",
+ "repo": "rust-overlay",
"type": "github"
}
},
diff --git a/flake.nix b/flake.nix
index 9e09a621..f435edc6 100644
--- a/flake.nix
+++ b/flake.nix
@@ -13,8 +13,8 @@
crane.url = "github:ipetkov/crane";
- fenix = {
- url = "github:nix-community/fenix";
+ rust-overlay = {
+ url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
@@ -30,9 +30,9 @@
nixpkgs,
flake-parts,
treefmt-nix,
- fenix,
crane,
- ...
+ rust-overlay,
+ flake-compat,
}:
let
systems = nixpkgs.lib.filter (s: nixpkgs.lib.hasSuffix "-linux" s)
nixpkgs.lib.systems.flakeExposed;
@@ -47,7 +47,6 @@
self',
config,
lib,
- pkgs,
system,
...
}:
@@ -56,6 +55,11 @@
inherit (lib.lists) findFirst;
inherit (lib.strings) hasPrefix removePrefix substring;
+ pkgs = import nixpkgs {
+ inherit system;
+ overlays = [ (import rust-overlay) ];
+ };
+
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
rustfmtToml = builtins.fromTOML (builtins.readFile ./rustfmt.toml);
@@ -198,7 +202,9 @@
nixfmt.enable = true;
rustfmt.edition = rustfmtToml.edition;
rustfmt.enable = true;
- rustfmt.package = fenix.packages.${system}.default.rustfmt;
+ rustfmt.package =
+ (pkgs.rust-bin.selectLatestNightlyWith (toolchain:
toolchain.rustfmt)).overrideAttrs
+ { meta.mainProgram = "rustfmt"; };
};
};
};
--
2.47.0