From 8a506bb4c8d327e583d8bf05e0a896910004c72f Mon Sep 17 00:00:00 2001 From: Youwen Wu Date: Thu, 12 Sep 2024 01:35:54 -0700 Subject: [PATCH] feat: use fenix instead of rust-overlay --- flake.lock | 62 +++++++++++++++++++++++++++++------------------------- flake.nix | 47 ++++++++++++++++++++++------------------- 2 files changed, 58 insertions(+), 51 deletions(-) diff --git a/flake.lock b/flake.lock index 2a46240..dc0513a 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,26 @@ { "nodes": { + "fenix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1726116637, + "narHash": "sha256-tU2GhwU887mPg6C4c2k+CEBAnKY6R0tSeQYtoqjZmLM=", + "owner": "nix-community", + "repo": "fenix", + "rev": "96a04a213838c5001619ad57400c5a176fa040b1", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, "flake-utils": { "inputs": { "systems": "systems" @@ -34,44 +55,27 @@ "type": "github" } }, - "nixpkgs_2": { - "locked": { - "lastModified": 1718428119, - "narHash": "sha256-WdWDpNaq6u1IPtxtYHHWpl5BmabtpmLnMAx0RdJ/vo8=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "e6cea36f83499eb4e9cd184c8a8e823296b50ad5", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, "root": { "inputs": { + "fenix": "fenix", "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs", - "rust-overlay": "rust-overlay" + "nixpkgs": "nixpkgs" } }, - "rust-overlay": { - "inputs": { - "nixpkgs": "nixpkgs_2" - }, + "rust-analyzer-src": { + "flake": false, "locked": { - "lastModified": 1723947704, - "narHash": "sha256-TcVf66N2NgGhxORFytzgqWcg0XJ+kk8uNLNsTRI5sYM=", - "owner": "oxalica", - "repo": "rust-overlay", - "rev": "456e78a55feade2c3bc6d7bc0bf5e710c9d86120", + "lastModified": 1725985110, + "narHash": "sha256-0HKj+JI6rtxaE6Kzcd6HyFNbEFJRsLy5DoNgVF1pyRM=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "bcc708992104c2059f310fbc3ac00bfc377f9ea8", "type": "github" }, "original": { - "owner": "oxalica", - "repo": "rust-overlay", + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", "type": "github" } }, diff --git a/flake.nix b/flake.nix index 8c226c2..da71ec3 100644 --- a/flake.nix +++ b/flake.nix @@ -4,22 +4,28 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; flake-utils.url = "github:numtide/flake-utils"; - rust-overlay.url = "github:oxalica/rust-overlay"; + fenix = { + url = "github:nix-community/fenix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; - outputs = { - nixpkgs, - flake-utils, - rust-overlay, - ... - }: + outputs = + { + nixpkgs, + flake-utils, + fenix, + ... + }: flake-utils.lib.eachDefaultSystem ( - system: let - overlays = [(import rust-overlay)]; - pkgs = import nixpkgs { - inherit system overlays; - }; - in { + system: + let + pkgs = import nixpkgs { inherit system; }; + rustPkgs = fenix.packages.${system}; + in + { + formatter = pkgs.nixfmt-rfc-style; + devShells = { go = pkgs.mkShell { buildInputs = with pkgs; [ @@ -58,23 +64,20 @@ }; rustBeta = pkgs.mkShell { - buildInputs = with pkgs; [ - rust-bin.beta.latest.default - rust-analyzer + buildInputs = [ + rustPkgs.beta.completeToolchain ]; }; rustNightly = pkgs.mkShell { - buildInputs = with pkgs; [ - rust-bin.nightly.latest.default - rust-analyzer + buildInputs = [ + rustPkgs.complete.toolchain ]; }; rustStable = pkgs.mkShell { - buildInputs = with pkgs; [ - rust-bin.stable.latest.default - rust-analyzer + buildInputs = [ + rustPkgs.stable.completeToolchain ]; };