mirror of
https://github.com/XNM1/linux-nixos-hyprland-config-dotfiles.git
synced 2025-09-15 09:45:58 +03:00
updated cargo\rust code snippets
This commit is contained in:
@@ -1 +0,0 @@
|
|||||||
rustflags = ["-C", "link-arg=-fuse-ld=/path/to/mold", "-Z", "threads=8" ] # Change '/path/to/mold', use with nightly version of Rust
|
|
@@ -1,8 +1,8 @@
|
|||||||
### Cargo code snippets for different optimizations
|
### 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)
|
## 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
|
# Work only with the nightly version of Rust by the time it was written; it is recommended NOT to use it in production for now
|
||||||
cargo-features = ["codegen-backend"]
|
cargo-features = [ "codegen-backend", "profile-rustflags" ]
|
||||||
# Important: It provides less useful error messages during compilation
|
# Important: It provides less useful error messages during compilation
|
||||||
[profile.dev]
|
[profile.dev]
|
||||||
opt-level = 1
|
opt-level = 1
|
||||||
@@ -11,10 +11,17 @@ codegen-backend = "cranelift"
|
|||||||
opt-level = 3
|
opt-level = 3
|
||||||
codegen-backend = "cranelift"
|
codegen-backend = "cranelift"
|
||||||
|
|
||||||
|
[profile.dev.build-override]
|
||||||
|
rustflags = [ "-Z", "threads=8", "-C", "link-arg=-fuse-ld=/run/current-system/sw/bin/mold" ] # `/run/current-system/sw/bin/mold` is an absolute path to the mold executable
|
||||||
|
|
||||||
## Release build size optimization (more https://github.com/johnthagen/min-sized-rust)
|
## Release build size optimization (more https://github.com/johnthagen/min-sized-rust)
|
||||||
|
# You can also use programs such as `upx` for size optimization
|
||||||
[profile.release]
|
[profile.release]
|
||||||
strip = true
|
strip = true
|
||||||
opt-level = "z" # Also can try 's' instead of 'z'
|
opt-level = "z" # You can try 's' instead of 'z' if you want to optimize for speed
|
||||||
lto = true
|
lto = true
|
||||||
codegen-units = 1
|
codegen-units = 1
|
||||||
panic = "abort"
|
panic = "abort" # DELETE extra unwinding code that provides helpful backtrace information for runtime errors
|
||||||
|
|
||||||
|
[profile.release.build-override]
|
||||||
|
rustflags = [ "-Z", "location-detail=none" ] # DELETE a useful traceback information such as file, line, and column information for panic!() and [track_caller]
|
||||||
|
130
home/Projects/optimized-pre-config-rust/flake.lock
generated
Normal file
130
home/Projects/optimized-pre-config-rust/flake.lock
generated
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"flake-utils": {
|
||||||
|
"inputs": {
|
||||||
|
"systems": "systems"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1694529238,
|
||||||
|
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"flake-utils_2": {
|
||||||
|
"inputs": {
|
||||||
|
"systems": "systems_2"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1681202837,
|
||||||
|
"narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"rev": "cfacdce06f30d2b68473a46042957675eebb3401",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1701253981,
|
||||||
|
"narHash": "sha256-ztaDIyZ7HrTAfEEUt9AtTDNoCYxUdSd6NrRHaYOIxtk=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "e92039b55bcd58469325ded85d4f58dd5a4eaf58",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixos-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs_2": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1681358109,
|
||||||
|
"narHash": "sha256-eKyxW4OohHQx9Urxi7TQlFBTDWII+F+x2hklDOQPB50=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "96ba1c52e54e74c3197f4d43026b3f3d92e83ff9",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixpkgs-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-utils": "flake-utils",
|
||||||
|
"nixpkgs": "nixpkgs",
|
||||||
|
"rust-overlay": "rust-overlay"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"rust-overlay": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-utils": "flake-utils_2",
|
||||||
|
"nixpkgs": "nixpkgs_2"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1701397143,
|
||||||
|
"narHash": "sha256-nYUJxZXwCWWVBYZXPgRxGDuQcZRhKTtD/Jp5Jl+9EWU=",
|
||||||
|
"owner": "oxalica",
|
||||||
|
"repo": "rust-overlay",
|
||||||
|
"rev": "bb71557c93cad40f5921b2342d7fd69f9e6497ab",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "oxalica",
|
||||||
|
"repo": "rust-overlay",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"systems": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1681028828,
|
||||||
|
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"systems_2": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1681028828,
|
||||||
|
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
@@ -7,7 +7,7 @@
|
|||||||
flake-utils.url = "github:numtide/flake-utils";
|
flake-utils.url = "github:numtide/flake-utils";
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self, nixpkgs, rust-overlay, flake-utils, ... }:
|
outputs = { nixpkgs, rust-overlay, flake-utils, ... }:
|
||||||
flake-utils.lib.eachDefaultSystem (system:
|
flake-utils.lib.eachDefaultSystem (system:
|
||||||
let
|
let
|
||||||
overlays = [ (import rust-overlay) ];
|
overlays = [ (import rust-overlay) ];
|
||||||
@@ -19,12 +19,11 @@
|
|||||||
{
|
{
|
||||||
devShells.default = mkShell {
|
devShells.default = mkShell {
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
|
just
|
||||||
(rust-bin.fromRustupToolchainFile ./rust-toolchain.toml)
|
(rust-bin.fromRustupToolchainFile ./rust-toolchain.toml)
|
||||||
mold
|
mold
|
||||||
pkg-config
|
|
||||||
openssl
|
|
||||||
sqlite
|
|
||||||
cargo-deny
|
cargo-deny
|
||||||
|
cargo-watch
|
||||||
cargo-audit
|
cargo-audit
|
||||||
cargo-update
|
cargo-update
|
||||||
cargo-edit
|
cargo-edit
|
||||||
@@ -37,9 +36,13 @@
|
|||||||
cargo-spellcheck
|
cargo-spellcheck
|
||||||
cargo-modules
|
cargo-modules
|
||||||
cargo-bloat
|
cargo-bloat
|
||||||
|
cargo-unused-features
|
||||||
taplo
|
taplo
|
||||||
bacon
|
bacon
|
||||||
helix
|
helix
|
||||||
|
pkg-config
|
||||||
|
openssl
|
||||||
|
sqlite
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
42
home/Projects/optimized-pre-config-rust/justfile
Normal file
42
home/Projects/optimized-pre-config-rust/justfile
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
set export
|
||||||
|
|
||||||
|
set shell := ["fish", "-c"]
|
||||||
|
|
||||||
|
alias w := watch
|
||||||
|
alias b := build
|
||||||
|
alias r := release
|
||||||
|
alias l := lint
|
||||||
|
alias t := test
|
||||||
|
alias c := coverage
|
||||||
|
|
||||||
|
# run `just --list` for project
|
||||||
|
default:
|
||||||
|
just --list
|
||||||
|
|
||||||
|
# run `cargo watch` for project
|
||||||
|
watch:
|
||||||
|
cargo watch
|
||||||
|
|
||||||
|
# run `cargo build` for project
|
||||||
|
build:
|
||||||
|
cargo build
|
||||||
|
|
||||||
|
# run `cargo build --release` for project
|
||||||
|
release: test
|
||||||
|
cargo build --release
|
||||||
|
|
||||||
|
# run `cargo zigbuild --target {target} --release` for project
|
||||||
|
cross target: test
|
||||||
|
cargo zigbuild --target $target --release
|
||||||
|
|
||||||
|
# run `cargo clippy` for project
|
||||||
|
lint:
|
||||||
|
cargo clippy
|
||||||
|
|
||||||
|
# run `carog nextest run` for project
|
||||||
|
test:
|
||||||
|
cargo nextest run
|
||||||
|
|
||||||
|
# run `cargo tarpaulin` for project
|
||||||
|
coverage:
|
||||||
|
cargo tarpaulin
|
Reference in New Issue
Block a user