dev-templates/rust/flake.nix
2022-07-28 23:20:46 +02:00

50 lines
1.1 KiB
Nix

{
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
overlays = [
(import rust-overlay)
];
pkgs = import nixpkgs {
inherit system overlays;
};
rust = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
inherit (pkgs) mkShell;
inherit (pkgs.lib) optionals;
inherit (pkgs.stdenv) isDarwin;
in {
packages.default = rust;
devShells = {
default = mkShell {
nativeBuildInputs = [
rust
pkgs.pkg-config
];
buildInputs = with pkgs; [
openssl
pkgconfig
];
shellHook = ''
echo "Entering Rust env"
echo "Running `${rust}/bin/cargo --version`"
'';
};
};
}
);
}