dev-templates/rust/flake.nix

38 lines
966 B
Nix
Raw Normal View History

2022-07-16 16:48:23 +02: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-29 00:11:05 +02:00
overlays = [ (import rust-overlay) ];
2022-07-16 16:48:23 +02:00
2022-07-29 00:11:05 +02:00
pkgs = import nixpkgs { inherit system overlays; };
2022-07-16 16:48:23 +02:00
rust = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
2022-07-28 23:54:27 +02:00
helpers = with pkgs; [ openssl pkg-config ];
2022-07-28 23:42:40 +02:00
2022-07-28 23:20:46 +02:00
inherit (pkgs) mkShell;
2022-07-16 16:48:23 +02:00
inherit (pkgs.lib) optionals;
inherit (pkgs.stdenv) isDarwin;
in {
packages.default = rust;
devShells = {
2022-07-28 23:20:46 +02:00
default = mkShell {
2022-07-29 00:11:05 +02:00
buildInputs = [ rust ] ++ helpers;
2022-07-16 16:48:23 +02:00
shellHook = ''
2022-07-28 23:42:40 +02:00
${rust}/bin/cargo --version
2022-07-16 16:48:23 +02:00
'';
};
};
2022-07-29 00:11:05 +02:00
});
2022-07-16 16:48:23 +02:00
}