From 4efc08c8ec8f0afdba10f00e2fa0b076e4321fac Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Mon, 15 May 2023 11:41:25 +0530 Subject: [PATCH] feat(nix): switch to provisioning toolchains using fenix rust-overlay's `fromRustupToolchainFile` does not provision the provided components from the `rust-toolchain.toml` file which makes the experience subpar compared to fenix that treats `rust-toolchain.toml` similar to rustup. --- flake.lock | 54 ++++++++++++++++++++++++++++++++++++++++++++++-------- flake.nix | 28 +++++++++++++--------------- 2 files changed, 59 insertions(+), 23 deletions(-) diff --git a/flake.lock b/flake.lock index 3c417a8..0acb70d 100644 --- a/flake.lock +++ b/flake.lock @@ -27,9 +27,7 @@ "nixpkgs": [ "nixpkgs" ], - "rust-overlay": [ - "rust-overlay" - ] + "rust-overlay": "rust-overlay" }, "locked": { "lastModified": 1683505101, @@ -45,6 +43,27 @@ "type": "github" } }, + "fenix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1684045209, + "narHash": "sha256-d6WRNsb5+P7wocC/wCMjkvF0pycKuZ7SHgj5NGmESNQ=", + "owner": "nix-community", + "repo": "fenix", + "rev": "7c8be7e3312ba06dc95491a44c3c9ba71a175bc4", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, "flake-compat": { "flake": false, "locked": { @@ -99,27 +118,46 @@ "inputs": { "advisory-db": "advisory-db", "crane": "crane", + "fenix": "fenix", "flake-compat": "flake-compat", "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs", - "rust-overlay": "rust-overlay" + "nixpkgs": "nixpkgs" + } + }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1684005690, + "narHash": "sha256-m0Dya15vVk4swQdWKqDYHmdU3cirySRjaQ6EgMa2Mcg=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "cbd14e98403dc5e19f19fdf913808656d81a0516", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" } }, "rust-overlay": { "inputs": { "flake-utils": [ + "crane", "flake-utils" ], "nixpkgs": [ + "crane", "nixpkgs" ] }, "locked": { - "lastModified": 1684030847, - "narHash": "sha256-z4tOxaN9Cl8C80u6wyZBpPt9A9MbL21fZ3zdB/vG+AU=", + "lastModified": 1684117262, + "narHash": "sha256-ZSF4CZqeyk6QwTjal73KPMuTWiU6w/p8ygEimrPb7u4=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "aa1480f16bec7dda3c62b8cdb184c7e823331ba2", + "rev": "4679872d2dd3e94ffef75efcbf77ea11549d90a7", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index d85cc6b..7197a98 100644 --- a/flake.nix +++ b/flake.nix @@ -4,6 +4,13 @@ inputs = { nixpkgs = {url = "github:NixOS/nixpkgs/nixpkgs-unstable";}; + fenix = { + url = "github:nix-community/fenix"; + inputs = { + nixpkgs.follows = "nixpkgs"; + }; + }; + flake-utils = {url = "github:numtide/flake-utils";}; flake-compat = { @@ -11,21 +18,12 @@ flake = false; }; - rust-overlay = { - url = "github:oxalica/rust-overlay"; - inputs = { - nixpkgs.follows = "nixpkgs"; - flake-utils.follows = "flake-utils"; - }; - }; - crane = { url = "github:ipetkov/crane"; inputs = { flake-compat.follows = "flake-compat"; flake-utils.follows = "flake-utils"; nixpkgs.follows = "nixpkgs"; - rust-overlay.follows = "rust-overlay"; }; }; @@ -38,20 +36,20 @@ outputs = { self, nixpkgs, + fenix, crane, flake-utils, advisory-db, - rust-overlay, ... }: flake-utils.lib.eachDefaultSystem (system: let - pkgs = import nixpkgs { - inherit system; - overlays = [(import rust-overlay)]; + pkgs = import nixpkgs {inherit system;}; + + rustStable = (import fenix {inherit pkgs;}).fromToolchainFile { + file = ./rust-toolchain.toml; + sha256 = "sha256-1elQHBWEQRZ5qrEtJi6uhvwUNKedyQusyhATdBywep0="; }; - rustStable = - pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; craneLib = (crane.mkLib pkgs).overrideToolchain rustStable; src = craneLib.cleanCargoSource ./.; nativeBuildInputs = [];