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";
|
|
|
|
};
|
|
|
|
|
2022-08-20 03:06:53 -07:00
|
|
|
outputs = { self, flake-utils, nixpkgs, rust-overlay }:
|
|
|
|
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-08-20 04:47:43 -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;
|
2022-07-31 14:03:09 -07:00
|
|
|
[ cargo-audit cargo-deny cargo-cross rust-analyzer ]
|
|
|
|
++ optionals isLinux (with pkgs; [ cargo-watch ]);
|
2022-08-20 04:47:43 -07:00
|
|
|
in
|
|
|
|
{
|
2022-07-16 07:48:23 -07:00
|
|
|
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
|
|
|
}
|