2022-07-16 16:48:23 +02:00
|
|
|
{
|
|
|
|
description = "A Nix-flake-based Rust development environment";
|
|
|
|
|
|
|
|
inputs = {
|
2023-07-14 02:12:42 +02:00
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
2022-07-16 16:48:23 +02:00
|
|
|
rust-overlay.url = "github:oxalica/rust-overlay";
|
|
|
|
};
|
|
|
|
|
2023-07-14 02:12:42 +02:00
|
|
|
outputs = { self, nixpkgs, rust-overlay }:
|
2022-08-20 14:54:34 +02:00
|
|
|
let
|
|
|
|
overlays = [
|
2023-07-14 02:12:42 +02:00
|
|
|
rust-overlay.overlays.default
|
|
|
|
(final: prev: {
|
2022-08-20 14:54:34 +02:00
|
|
|
rustToolchain =
|
|
|
|
let
|
2023-07-14 02:12:42 +02:00
|
|
|
rust = prev.rust-bin;
|
2022-08-20 14:54:34 +02:00
|
|
|
in
|
|
|
|
if builtins.pathExists ./rust-toolchain.toml then
|
|
|
|
rust.fromRustupToolchainFile ./rust-toolchain.toml
|
|
|
|
else if builtins.pathExists ./rust-toolchain then
|
|
|
|
rust.fromRustupToolchainFile ./rust-toolchain
|
|
|
|
else
|
|
|
|
rust.stable.latest.default;
|
|
|
|
})
|
|
|
|
];
|
2023-07-14 02:12:42 +02:00
|
|
|
supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
|
|
|
|
forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f {
|
|
|
|
pkgs = import nixpkgs { inherit overlays system; };
|
|
|
|
});
|
2022-08-20 14:54:34 +02:00
|
|
|
in
|
|
|
|
{
|
2023-07-14 02:12:42 +02:00
|
|
|
devShells = forEachSupportedSystem ({ pkgs }: {
|
|
|
|
default = pkgs.mkShell {
|
|
|
|
packages = with pkgs; [
|
2022-08-20 14:54:34 +02:00
|
|
|
rustToolchain
|
|
|
|
openssl
|
|
|
|
pkg-config
|
|
|
|
cargo-deny
|
2022-08-28 15:26:43 +02:00
|
|
|
cargo-edit
|
2022-10-28 02:45:13 +02:00
|
|
|
cargo-watch
|
2022-08-20 14:54:34 +02:00
|
|
|
rust-analyzer
|
2022-10-28 02:45:13 +02:00
|
|
|
];
|
2023-07-14 02:12:42 +02:00
|
|
|
};
|
|
|
|
});
|
|
|
|
};
|
2022-07-16 16:48:23 +02:00
|
|
|
}
|