feat(nix): replace fenix with rust-overlay

We're going to use rust-overlay for setting up an MSRV build.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
Thomas Mühlbacher 2025-03-21 16:33:58 +00:00 committed by Kent Overstreet
parent 0a23a5ab1a
commit 197437be12
2 changed files with 24 additions and 38 deletions

46
flake.lock generated
View File

@ -15,27 +15,6 @@
"type": "github" "type": "github"
} }
}, },
"fenix": {
"inputs": {
"nixpkgs": [
"nixpkgs"
],
"rust-analyzer-src": "rust-analyzer-src"
},
"locked": {
"lastModified": 1742452566,
"narHash": "sha256-sVuLDQ2UIWfXUBbctzrZrXM2X05YjX08K7XHMztt36E=",
"owner": "nix-community",
"repo": "fenix",
"rev": "7d9ba794daf5e8cc7ee728859bc688d8e26d5f06",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "fenix",
"type": "github"
}
},
"flake-compat": { "flake-compat": {
"flake": false, "flake": false,
"locked": { "locked": {
@ -104,27 +83,30 @@
"root": { "root": {
"inputs": { "inputs": {
"crane": "crane", "crane": "crane",
"fenix": "fenix",
"flake-compat": "flake-compat", "flake-compat": "flake-compat",
"flake-parts": "flake-parts", "flake-parts": "flake-parts",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"rust-overlay": "rust-overlay",
"treefmt-nix": "treefmt-nix" "treefmt-nix": "treefmt-nix"
} }
}, },
"rust-analyzer-src": { "rust-overlay": {
"flake": false, "inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": { "locked": {
"lastModified": 1742296961, "lastModified": 1742524367,
"narHash": "sha256-gCpvEQOrugHWLimD1wTFOJHagnSEP6VYBDspq96Idu0=", "narHash": "sha256-KzTwk/5ETJavJZYV1DEWdCx05M4duFCxCpRbQSKWpng=",
"owner": "rust-lang", "owner": "oxalica",
"repo": "rust-analyzer", "repo": "rust-overlay",
"rev": "15d87419f1a123d8f888d608129c3ce3ff8f13d4", "rev": "70bf752d176b2ce07417e346d85486acea9040ef",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "rust-lang", "owner": "oxalica",
"ref": "nightly", "repo": "rust-overlay",
"repo": "rust-analyzer",
"type": "github" "type": "github"
} }
}, },

View File

@ -13,8 +13,8 @@
crane.url = "github:ipetkov/crane"; crane.url = "github:ipetkov/crane";
fenix = { rust-overlay = {
url = "github:nix-community/fenix"; url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
@ -30,9 +30,9 @@
nixpkgs, nixpkgs,
flake-parts, flake-parts,
treefmt-nix, treefmt-nix,
fenix,
crane, crane,
... rust-overlay,
flake-compat,
}: }:
let let
systems = nixpkgs.lib.filter (s: nixpkgs.lib.hasSuffix "-linux" s) nixpkgs.lib.systems.flakeExposed; systems = nixpkgs.lib.filter (s: nixpkgs.lib.hasSuffix "-linux" s) nixpkgs.lib.systems.flakeExposed;
@ -47,7 +47,6 @@
self', self',
config, config,
lib, lib,
pkgs,
system, system,
... ...
}: }:
@ -56,6 +55,11 @@
inherit (lib.lists) findFirst; inherit (lib.lists) findFirst;
inherit (lib.strings) hasPrefix removePrefix substring; inherit (lib.strings) hasPrefix removePrefix substring;
pkgs = import nixpkgs {
inherit system;
overlays = [ (import rust-overlay) ];
};
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml); cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
rustfmtToml = builtins.fromTOML (builtins.readFile ./rustfmt.toml); rustfmtToml = builtins.fromTOML (builtins.readFile ./rustfmt.toml);
@ -198,7 +202,7 @@
nixfmt.enable = true; nixfmt.enable = true;
rustfmt.edition = rustfmtToml.edition; rustfmt.edition = rustfmtToml.edition;
rustfmt.enable = true; rustfmt.enable = true;
rustfmt.package = fenix.packages.${system}.default.rustfmt; rustfmt.package = pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.rustfmt);
}; };
}; };
}; };