From e566bd0822017e2c726f598fee294e59f711ff02 Mon Sep 17 00:00:00 2001 From: Luc Perkins Date: Fri, 29 Jul 2022 02:29:34 +0200 Subject: [PATCH] Make Rust env more robust --- rust/flake.nix | 14 +++++++++++--- rust/rust-toolchain.toml | 2 -- 2 files changed, 11 insertions(+), 5 deletions(-) delete mode 100644 rust/rust-toolchain.toml diff --git a/rust/flake.nix b/rust/flake.nix index 97f1b46..7602efa 100644 --- a/rust/flake.nix +++ b/rust/flake.nix @@ -13,10 +13,16 @@ overlays = [ (import rust-overlay) ]; pkgs = import nixpkgs { inherit system overlays; }; + inherit (pkgs) rust-bin; - rust = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; + rust = if builtins.pathExists ./rust-toolchain.toml then + rust-bin.fromRustupToolchainFile ./rust-toolchain.toml + else if builtins.pathExists ./rust-toolchain then + rust-bin.fromRustupToolchainFile ./rust-toolchain + else + rust-bin.stable.latest.default; - helpers = with pkgs; [ openssl pkg-config ]; + helpers = with pkgs; [ openssl pkgconfig ]; inherit (pkgs) mkShell; inherit (pkgs.lib) optionals; @@ -26,7 +32,9 @@ devShells = { default = mkShell { - buildInputs = [ rust ] ++ helpers; + nativeBuildInputs = [ rust ]; + + buildInputs = helpers; shellHook = '' ${rust}/bin/cargo --version diff --git a/rust/rust-toolchain.toml b/rust/rust-toolchain.toml deleted file mode 100644 index 05dfa32..0000000 --- a/rust/rust-toolchain.toml +++ /dev/null @@ -1,2 +0,0 @@ -[toolchain] -channel = "1.62.0"