From 197437be12b850eae87a1957117e20d605fe1189 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BChlbacher?= <tmuehlbacher@posteo.net> Date: Fri, 21 Mar 2025 16:33:58 +0000 Subject: [PATCH] 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> --- flake.lock | 46 ++++++++++++++-------------------------------- flake.nix | 16 ++++++++++------ 2 files changed, 24 insertions(+), 38 deletions(-) diff --git a/flake.lock b/flake.lock index d8a0ace7..c8ea8d15 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": 1742452566, - "narHash": "sha256-sVuLDQ2UIWfXUBbctzrZrXM2X05YjX08K7XHMztt36E=", - "owner": "nix-community", - "repo": "fenix", - "rev": "7d9ba794daf5e8cc7ee728859bc688d8e26d5f06", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "fenix", - "type": "github" - } - }, "flake-compat": { "flake": false, "locked": { @@ -104,27 +83,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": 1742296961, - "narHash": "sha256-gCpvEQOrugHWLimD1wTFOJHagnSEP6VYBDspq96Idu0=", - "owner": "rust-lang", - "repo": "rust-analyzer", - "rev": "15d87419f1a123d8f888d608129c3ce3ff8f13d4", + "lastModified": 1742524367, + "narHash": "sha256-KzTwk/5ETJavJZYV1DEWdCx05M4duFCxCpRbQSKWpng=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "70bf752d176b2ce07417e346d85486acea9040ef", "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..5f93f522 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,7 @@ 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); }; }; };