Last active
August 26, 2024 18:13
-
-
Save tristandruyen/7c0554cbbf5722e9081f2ea7de53f3a0 to your computer and use it in GitHub Desktop.
Rust Devshell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ! has nix_direnv_version || ! nix_direnv_version 2.3.0; then | |
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.3.0/direnvrc" "sha256-Dmd+j63L84wuzgyjITIfSxSD57Tx7v51DMxVZOsiUD8=" | |
fi | |
use flake |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
description = "A Nix-flake-based Rust development environment"; | |
inputs = { | |
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; | |
rust-overlay.url = "github:oxalica/rust-overlay"; | |
flake-utils.url = "github:numtide/flake-utils"; | |
devshell.url = "github:numtide/devshell"; | |
}; | |
outputs = | |
{ self | |
, nixpkgs | |
, rust-overlay | |
, flake-utils | |
, devshell | |
, npmlock2nix | |
, | |
}: | |
flake-utils.lib.eachDefaultSystem | |
(system: | |
let | |
overlays = [ | |
rust-overlay.overlays.default | |
devshell.overlays.default | |
(final: prev: { | |
customRustToolchain = prev.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; | |
}) | |
]; | |
pkgs = import nixpkgs { | |
inherit system overlays; | |
}; | |
# add library dev deps here ######################################### | |
buildInputs = with pkgs; [ | |
harfbuzz | |
openssl | |
pango | |
sqlite | |
mariadb | |
zlib | |
clang | |
libclang | |
gzip | |
coreutils | |
glib | |
glibc | |
]; | |
in | |
{ | |
apps.devshell = self.outputs.devShells.${system}.default.flakeApp; | |
devShells.default = pkgs.mkShell { | |
packages = with pkgs; # add binary devtools here ################## | |
[ | |
customRustToolchain | |
binaryen | |
cacert | |
cargo-bloat | |
cargo-docset | |
cargo-machete | |
cargo-limit | |
cargo-deny | |
cargo-edit | |
cargo-watch | |
cargo-make | |
cargo-udeps | |
cargo-outdated | |
cargo-release | |
pkg-config | |
unzip | |
] | |
++ buildInputs; | |
buildInputs = buildInputs; | |
shellHook = '' | |
export MALLOC_CONF=thp:always,metadata_thp:always | |
''; | |
}; | |
}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[toolchain] | |
channel = "nightly-2024-08-20" | |
targets = [ | |
"x86_64-unknown-linux-gnu", | |
"wasm32-unknown-unknown", # you might not need this | |
"x86_64-pc-windows-msvc", # | |
] | |
components = [ | |
"cargo", | |
"rustfmt", | |
"rust-analyzer", | |
"rust-src", | |
"rustc-codegen-cranelift", | |
"rustc-dev", | |
] | |
profile = "default" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment