From 3e0b846a3a599281b16cc7fabd9d42edf5c42066 Mon Sep 17 00:00:00 2001 From: uku Date: Sat, 27 Jul 2024 19:42:35 +0200 Subject: [PATCH] feat: switch to rust-overlay --- flake.lock | 23 ++++++++++++++++++++++- flake.nix | 32 ++++++++++++++++++++++++++------ 2 files changed, 48 insertions(+), 7 deletions(-) diff --git a/flake.lock b/flake.lock index 2940b56..9503b9d 100644 --- a/flake.lock +++ b/flake.lock @@ -39,7 +39,28 @@ "root": { "inputs": { "flake-parts": "flake-parts", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1722046723, + "narHash": "sha256-G7/gHz8ORRvHd1/RIURrdcswKRPe9K0FsIYR4v5jSWo=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "56baac5e6b2743d4730e664ea64f6d8a2aad0fbb", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" } } }, diff --git a/flake.nix b/flake.nix index 35b8835..50c0630 100644 --- a/flake.nix +++ b/flake.nix @@ -6,11 +6,18 @@ url = "github:hercules-ci/flake-parts"; inputs.nixpkgs-lib.follows = "nixpkgs"; }; + + rust-overlay = { + url = "github:oxalica/rust-overlay"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; outputs = { self, + nixpkgs, flake-parts, + rust-overlay, ... } @ inputs: flake-parts.lib.mkFlake {inherit inputs;} { @@ -18,17 +25,30 @@ perSystem = { lib, - pkgs, + system, self', ... - }: { - packages.default = pkgs.callPackage ./derivation.nix {inherit self;}; + }: let + pkgs = import nixpkgs { + inherit system; + overlays = [(import rust-overlay)]; + }; + + toolchain = pkgs.rust-bin.stable.latest.default; + rustPlatform = pkgs.makeRustPlatform { + rustc = toolchain; + cargo = toolchain; + }; + in { + packages.default = pkgs.callPackage ./derivation.nix {inherit self rustPlatform;}; devShells.default = with pkgs; mkShell { - packages = [clippy rustfmt rust-analyzer]; - inputsFrom = [self'.packages.default]; - RUST_SRC_PATH = "${pkgs.rustPlatform.rustLibSrc}"; + buildInputs = [ + (toolchain.override { + extensions = ["rust-analyzer" "rust-src"]; + }) + ]; }; formatter = pkgs.alejandra;