dev-templates/rust/flake.nix

55 lines
1.3 KiB
Nix
Raw Normal View History

2022-07-16 07:48:23 -07:00
{
description = "A Nix-flake-based Rust development environment";
inputs = {
2022-08-20 03:06:53 -07:00
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:NixOS/nixpkgs";
2022-07-16 07:48:23 -07:00
rust-overlay.url = "github:oxalica/rust-overlay";
};
outputs =
{ self
, flake-utils
, nixpkgs
, rust-overlay
}:
2022-07-16 07:48:23 -07:00
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
{
2022-10-12 14:42:34 -07:00
devShells.default = pkgs.mkShell {
2023-02-14 16:20:41 -08:00
packages = with pkgs; [
rustToolchain
openssl
pkg-config
cargo-deny
2022-08-28 06:26:43 -07:00
cargo-edit
2022-10-27 17:45:13 -07:00
cargo-watch
rust-analyzer
2022-10-27 17:45:13 -07:00
];
shellHook = ''
${pkgs.rustToolchain}/bin/cargo --version
'';
};
});
2022-07-16 07:48:23 -07:00
}