60 lines
2.0 KiB
Nix
60 lines
2.0 KiB
Nix
# Rust shells. The toolchain is fenix's (inputs.fenix): rustc, cargo, clippy,
|
|
# rustfmt, rust-src, llvm-tools and the rust-analyzer of the same release, so the
|
|
# editor's language server (rustaceanvim) always matches the compiler.
|
|
# rust stable
|
|
# rust-nightly the latest nightly, same components and tools
|
|
# Knob: the fenix channel given to `rustShell`: "stable", "beta" or "latest"
|
|
# (nightly). A project pinned by rust-toolchain.toml is better served by a flake
|
|
# of its own (fenix.packages.<system>.fromToolchainFile).
|
|
{
|
|
perSystem =
|
|
{ inputs', pkgs, ... }:
|
|
let
|
|
rustShell =
|
|
channel: description:
|
|
let
|
|
toolchain = inputs'.fenix.packages.${channel}.withComponents [
|
|
"cargo"
|
|
"clippy"
|
|
"rust-src"
|
|
"rustc"
|
|
"rustfmt"
|
|
"rust-analyzer"
|
|
"llvm-tools" # llvm-cov and llvm-profdata for cargo-llvm-cov
|
|
];
|
|
in
|
|
{
|
|
inherit description;
|
|
packages = [
|
|
toolchain
|
|
pkgs.cargo-nextest
|
|
pkgs.cargo-expand
|
|
pkgs.cargo-edit
|
|
pkgs.bacon
|
|
# Debuggers (codelldb for nvim-dap comes with the editor, modules/cli/neovim.nix).
|
|
pkgs.lldb
|
|
pkgs.gdb
|
|
# -sys crates (openssl-sys, ...) find their C libraries through pkg-config.
|
|
pkgs.pkg-config
|
|
pkgs.openssl
|
|
pkgs.dav1d
|
|
pkgs.libvpx
|
|
pkgs.alsa-lib
|
|
pkgs.alsa-lib.dev
|
|
pkgs.libopus
|
|
pkgs.fontconfig
|
|
pkgs.pipewire
|
|
pkgs.pipewire.dev
|
|
pkgs.fontconfig.dev
|
|
];
|
|
env.RUST_SRC_PATH = "${toolchain}/lib/rustlib/src/rust/library";
|
|
};
|
|
in
|
|
{
|
|
shells = {
|
|
rust = rustShell "stable" "Rust stable (fenix): cargo, clippy, rustfmt, rust-analyzer, nextest, llvm-cov, bacon, lldb/gdb";
|
|
rust-nightly = rustShell "latest" "Rust nightly (fenix latest) with the tools of `rust`";
|
|
};
|
|
};
|
|
}
|