2022-07-16 07:48:23 -07:00
|
|
|
{
|
|
|
|
description = "A Nix-flake-based Rust development environment";
|
|
|
|
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs";
|
|
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
|
|
rust-overlay.url = "github:oxalica/rust-overlay";
|
|
|
|
};
|
|
|
|
|
|
|
|
outputs = { self, nixpkgs, flake-utils, rust-overlay }:
|
|
|
|
flake-utils.lib.eachDefaultSystem (system:
|
|
|
|
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-28 17:29:34 -07:00
|
|
|
inherit (pkgs) rust-bin;
|
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-28 17:29:34 -07:00
|
|
|
helpers = with pkgs; [ openssl pkgconfig ];
|
2022-07-28 14:42:40 -07:00
|
|
|
|
2022-07-28 14:20:46 -07:00
|
|
|
inherit (pkgs) mkShell;
|
2022-07-16 07:48:23 -07:00
|
|
|
inherit (pkgs.lib) optionals;
|
|
|
|
inherit (pkgs.stdenv) isDarwin;
|
|
|
|
in {
|
|
|
|
packages.default = rust;
|
|
|
|
|
|
|
|
devShells = {
|
2022-07-28 14:20:46 -07:00
|
|
|
default = mkShell {
|
2022-07-28 17:29:34 -07:00
|
|
|
nativeBuildInputs = [ rust ];
|
|
|
|
|
|
|
|
buildInputs = helpers;
|
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
|
|
|
}
|