mirror of
https://github.com/XNM1/linux-nixos-hyprland-config-dotfiles.git
synced 2025-09-15 09:45:58 +03:00
added dev shell example for Rust
This commit is contained in:
1
home/Projects/optimized-pre-config-rust/.cargo/config
Normal file
1
home/Projects/optimized-pre-config-rust/.cargo/config
Normal file
@@ -0,0 +1 @@
|
|||||||
|
rustflags = ["-C", "link-arg=-fuse-ld=/path/to/mold", "-Zcodegen-backend=cranelift" ] # Change '/path/to/mold' and DON'T use it in production, only for dev needs
|
20
home/Projects/optimized-pre-config-rust/Cargo.toml
Normal file
20
home/Projects/optimized-pre-config-rust/Cargo.toml
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
### Cargo code snippets for different optimizations
|
||||||
|
|
||||||
|
## Dev build compilation speed optimization (more https://benw.is/posts/how-i-improved-my-rust-compile-times-by-seventy-five-percent)
|
||||||
|
# Work only with nightly version of Rust by the time when it was written, also DON'T use it in production for now
|
||||||
|
cargo-features = ["codegen-backend"]
|
||||||
|
# Important: It provides less useful error messages during compilation
|
||||||
|
[profile.dev]
|
||||||
|
opt-level = 1
|
||||||
|
codegen-backend = "cranelift"
|
||||||
|
[profile.dev.package."*"]
|
||||||
|
opt-level = 3
|
||||||
|
codegen-backend = "cranelift"
|
||||||
|
|
||||||
|
## Release build size optimization (more https://github.com/johnthagen/min-sized-rust)
|
||||||
|
[profile.release]
|
||||||
|
strip = true
|
||||||
|
opt-level = "z" # Also can try 's' instead of 'z'
|
||||||
|
lto = true
|
||||||
|
codegen-units = 1
|
||||||
|
panic = "abort"
|
47
home/Projects/optimized-pre-config-rust/flake.nix
Normal file
47
home/Projects/optimized-pre-config-rust/flake.nix
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
{
|
||||||
|
description = "A devShell for Rust Development";
|
||||||
|
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
|
rust-overlay.url = "github:oxalica/rust-overlay";
|
||||||
|
flake-utils.url = "github:numtide/flake-utils";
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = { self, nixpkgs, rust-overlay, flake-utils, ... }:
|
||||||
|
flake-utils.lib.eachDefaultSystem (system:
|
||||||
|
let
|
||||||
|
overlays = [ (import rust-overlay) ];
|
||||||
|
pkgs = import nixpkgs {
|
||||||
|
inherit system overlays;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
with pkgs;
|
||||||
|
{
|
||||||
|
devShells.default = mkShell {
|
||||||
|
buildInputs = [
|
||||||
|
(rust-bin.fromRustupToolchainFile ./rust-toolchain.toml)
|
||||||
|
mold
|
||||||
|
pkg-config
|
||||||
|
openssl
|
||||||
|
sqlite
|
||||||
|
cargo-deny
|
||||||
|
cargo-audit
|
||||||
|
cargo-update
|
||||||
|
cargo-edit
|
||||||
|
cargo-outdated
|
||||||
|
cargo-license
|
||||||
|
cargo-tarpaulin
|
||||||
|
cargo-cross
|
||||||
|
cargo-zigbuild
|
||||||
|
cargo-nextest
|
||||||
|
cargo-spellcheck
|
||||||
|
cargo-modules
|
||||||
|
cargo-bloat
|
||||||
|
taplo
|
||||||
|
bacon
|
||||||
|
helix
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
10
home/Projects/optimized-pre-config-rust/rust-toolchain.toml
Normal file
10
home/Projects/optimized-pre-config-rust/rust-toolchain.toml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
[toolchain]
|
||||||
|
channel = "nightly"
|
||||||
|
components = [ "rust-src", "rust-analyzer", "rustc-codegen-cranelift", "miri", "llvm-tools", "rust-docs-json" ]
|
||||||
|
targets = [
|
||||||
|
"wasm32-wasi",
|
||||||
|
"wasm32-wasi-preview1-threads",
|
||||||
|
"x86_64-pc-windows-gnu",
|
||||||
|
"x86_64-unknown-linux-gnu",
|
||||||
|
]
|
||||||
|
profile = "default"
|
@@ -446,6 +446,7 @@
|
|||||||
# List packages installed in system profile. To search, run:
|
# List packages installed in system profile. To search, run:
|
||||||
# $ nix search wget
|
# $ nix search wget
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
|
mold
|
||||||
gcc13
|
gcc13
|
||||||
jdk11
|
jdk11
|
||||||
gleam
|
gleam
|
||||||
|
Reference in New Issue
Block a user