dev-templates/rust/flake.nix
2023-02-14 16:20:41 -08:00

55 lines
1.3 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 =
let
rust = super.rust-bin;
in
if builtins.pathExists ./rust-toolchain.toml then
rust.fromRustupToolchainFile ./rust-toolchain.toml
else if builtins.pathExists ./rust-toolchain then
rust.fromRustupToolchainFile ./rust-toolchain
else
rust.stable.latest.default;
})
];
pkgs = import nixpkgs { inherit system overlays; };
in
{
devShells.default = pkgs.mkShell {
packages = with pkgs; [
rustToolchain
openssl
pkg-config
cargo-deny
cargo-edit
cargo-watch
rust-analyzer
];
shellHook = ''
${pkgs.rustToolchain}/bin/cargo --version
'';
};
});
}