dev-templates/rust-toolchain/flake.nix
2022-10-20 16:14:56 +02:00

45 lines
1 KiB
Nix

{
description = "A Nix-flake-based Rust development environment";
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:NixOS/nixpkgs";
rust-overlay.url = "github:oxalica/rust-overlay";
};
outputs =
{ self
, flake-utils
, nixpkgs
, rust-overlay
}:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [
(import rust-overlay)
(self: super: {
rustToolchain = super.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
})
];
pkgs = import nixpkgs { inherit system overlays; };
in
{
devShells.default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
rustToolchain
openssl
pkg-config
cargo-deny
cargo-edit
rust-analyzer
] ++ pkgs.lib.optionals (pkgs.stdenv.isLinux) (with pkgs; [ cargo-watch ]); # Currently broken on macOS
shellHook = ''
${pkgs.rustToolchain}/bin/cargo --version
'';
};
});
}