From 75446b8cce74f2f94a6aa17c4098225e6d8a4a0e Mon Sep 17 00:00:00 2001 From: sgoudham Date: Sun, 2 Jul 2023 21:16:41 +0100 Subject: [PATCH] refactor(nix): use rust-toolchain.toml --- flake.lock | 26 +++++++++++++++++++++++++- flake.nix | 12 +++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/flake.lock b/flake.lock index b63755e..1cc322c 100644 --- a/flake.lock +++ b/flake.lock @@ -95,7 +95,8 @@ "inputs": { "crane": "crane", "flake-utils": "flake-utils_2", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay_2" } }, "rust-overlay": { @@ -123,6 +124,29 @@ "type": "github" } }, + "rust-overlay_2": { + "inputs": { + "flake-utils": [ + "flake-utils" + ], + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1688265347, + "narHash": "sha256-oe3kLnNvw2VWbG4Rp6IWUO5Uu5gF8J2oq8DbqbCsdZ4=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "b8f3db465405014039985f1c5cea92cc29e1b3b5", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, "systems": { "locked": { "lastModified": 1681028828, diff --git a/flake.nix b/flake.nix index d82b25f..8eeeb70 100644 --- a/flake.nix +++ b/flake.nix @@ -6,6 +6,13 @@ inputs.nixpkgs.follows = "nixpkgs"; }; flake-utils.url = "github:numtide/flake-utils"; + rust-overlay = { + url = "github:oxalica/rust-overlay"; + inputs = { + nixpkgs.follows = "nixpkgs"; + flake-utils.follows = "flake-utils"; + }; + }; }; outputs = { @@ -13,14 +20,17 @@ nixpkgs, crane, flake-utils, + rust-overlay, ... }: flake-utils.lib.eachDefaultSystem (system: let pkgs = import nixpkgs { inherit system; + overlays = [(import rust-overlay)]; }; - craneLib = crane.lib.${system}; + rustTarget = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; + craneLib = (crane.mkLib pkgs).overrideToolchain rustTarget; git-view = craneLib.buildPackage { src = craneLib.cleanCargoSource (craneLib.path ./.); buildInputs = [] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [pkgs.libiconv];