2022-07-16 07:48:23 -07:00
|
|
|
{
|
|
|
|
description = "A Nix-flake-based Rust development environment";
|
|
|
|
|
|
|
|
inputs = {
|
2022-07-31 03:57:49 -07:00
|
|
|
dev.url = "github:the-nix-way/dev-templates";
|
2022-07-16 07:48:23 -07:00
|
|
|
rust-overlay.url = "github:oxalica/rust-overlay";
|
|
|
|
};
|
|
|
|
|
2022-07-31 03:57:49 -07:00
|
|
|
outputs = { self, dev, rust-overlay }:
|
2022-07-31 04:02:06 -07:00
|
|
|
let inherit (dev.lib) flake-utils nixpkgs;
|
2022-07-31 03:57:49 -07:00
|
|
|
in flake-utils.lib.eachDefaultSystem (system:
|
2022-07-16 07:48:23 -07:00
|
|
|
let
|
2022-07-28 15:11:05 -07:00
|
|
|
overlays = [ (import rust-overlay) ];
|
2022-07-16 07:48:23 -07:00
|
|
|
|
2022-07-28 15:11:05 -07:00
|
|
|
pkgs = import nixpkgs { inherit system overlays; };
|
2022-07-31 07:47:47 -07:00
|
|
|
|
|
|
|
inherit (pkgs) mkShell rust-bin;
|
|
|
|
inherit (pkgs.lib) optionals;
|
|
|
|
inherit (pkgs.stdenv) isLinux;
|
2022-07-16 07:48:23 -07:00
|
|
|
|
2022-07-28 17:29:34 -07:00
|
|
|
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;
|
2022-07-16 07:48:23 -07:00
|
|
|
|
2022-07-31 07:47:47 -07:00
|
|
|
deps = with pkgs; [ openssl pkgconfig ];
|
|
|
|
rustTools = with pkgs;
|
|
|
|
[ cargo-profiler rust-analyzer ] ++ optionals isLinux (with pkgs; [ cargo-watch ]);
|
2022-07-16 07:48:23 -07:00
|
|
|
in {
|
|
|
|
packages.default = rust;
|
|
|
|
|
|
|
|
devShells = {
|
2022-07-28 14:20:46 -07:00
|
|
|
default = mkShell {
|
2022-07-31 07:47:47 -07:00
|
|
|
nativeBuildInputs = [ rust ] ++ deps ++ rustTools;
|
2022-07-16 07:48:23 -07:00
|
|
|
|
|
|
|
shellHook = ''
|
2022-07-28 14:42:40 -07:00
|
|
|
${rust}/bin/cargo --version
|
2022-07-16 07:48:23 -07:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
2022-07-28 15:11:05 -07:00
|
|
|
});
|
2022-07-16 07:48:23 -07:00
|
|
|
}
|