From 677aab11b9dab47907e333fcf666b3056964a7e4 Mon Sep 17 00:00:00 2001 From: Michael-J-Ward Date: Fri, 6 Sep 2024 14:19:34 -0500 Subject: [PATCH] add toolchain.toml --- flake.lock | 21 +++++++++++++++++++++ flake.nix | 19 ++++++++++++++++--- toolchain.toml | 6 ++++++ 3 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 toolchain.toml diff --git a/flake.lock b/flake.lock index 77158bafb..9333b236b 100644 --- a/flake.lock +++ b/flake.lock @@ -72,10 +72,31 @@ "inputs": { "flake-parts": "flake-parts", "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay", "systems": "systems", "treefmt-nix": "treefmt-nix" } }, + "rust-overlay": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1724206841, + "narHash": "sha256-L8dKaX4T3k+TR2fEHCfGbH4UXdspovz/pj87iai9qmc=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "45e98fbd62c32e5927e952d2833fa1ba4fb35a61", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, "systems": { "locked": { "lastModified": 1681028828, diff --git a/flake.nix b/flake.nix index 0bdb3a3b2..f9f54dd59 100644 --- a/flake.nix +++ b/flake.nix @@ -2,6 +2,10 @@ inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + rust-overlay = { + url = "github:oxalica/rust-overlay"; + inputs.nixpkgs.follows = "nixpkgs"; + }; flake-parts.url = "github:hercules-ci/flake-parts"; systems.url = "github:nix-systems/default"; # Dev tools @@ -14,8 +18,13 @@ imports = [ inputs.treefmt-nix.flakeModule ]; - perSystem = { config, self', pkgs, lib, system, ... }: + perSystem = { config, self', lib, system, ... }: let + pkgs = import inputs.nixpkgs { + inherit system; + overlays = [ (import inputs.rust-overlay) ]; + config = { }; + }; cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml); nonRustDeps = [ pkgs.pkg-config @@ -27,8 +36,7 @@ rust-toolchain = python: pkgs.symlinkJoin { name = "rust-toolchain"; paths = [ - pkgs.rustc - pkgs.cargo + (pkgs.rust-bin.fromRustupToolchainFile ./toolchain.toml) pkgs.clippy pkgs.cargo-watch pkgs.rust-analyzer @@ -40,6 +48,11 @@ python-pkgs.polars ])) pkgs.maturin + # used for cargo llvm-cov coverage + # pkgs.grcov + # pkgs.cargo-binutils + # pkgs.cargo-llvm-cov + # pkgs.rustc.llvmPackages.llvm ]; }; NIX_LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [ diff --git a/toolchain.toml b/toolchain.toml new file mode 100644 index 000000000..a09ee20ad --- /dev/null +++ b/toolchain.toml @@ -0,0 +1,6 @@ +# toolchain.toml +[toolchain] +channel = "stable" +components = [ "rustfmt", "rust-src", "llvm-tools" ] +profile = "default" +