Add template for rust library crate
This commit is contained in:
parent
f64c01ab6f
commit
4c7de9b72c
12
templates/rust/crate-lib/.editorconfig
Normal file
12
templates/rust/crate-lib/.editorconfig
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# EditorConfig is awesome: https://EditorConfig.org
|
||||||
|
|
||||||
|
# top-most EditorConfig file
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
|
end_of_line = lf
|
||||||
|
charset = utf-8
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
insert_final_newline = true
|
1
templates/rust/crate-lib/.envrc
Normal file
1
templates/rust/crate-lib/.envrc
Normal file
@ -0,0 +1 @@
|
|||||||
|
use flake
|
2
templates/rust/crate-lib/.gitignore
vendored
Normal file
2
templates/rust/crate-lib/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
/target
|
||||||
|
.envrc
|
0
templates/rust/crate-lib/Cargo.toml
Normal file
0
templates/rust/crate-lib/Cargo.toml
Normal file
44
templates/rust/crate-lib/flake.nix
Normal file
44
templates/rust/crate-lib/flake.nix
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
{
|
||||||
|
description = "@project_description@";
|
||||||
|
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||||
|
rust-overlay ={
|
||||||
|
url = "github:oxalica/rust-overlay";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = { nixpkgs, rust-overlay, ... }:
|
||||||
|
let
|
||||||
|
system = "x86_64-linux";
|
||||||
|
|
||||||
|
overlays = [ (import rust-overlay) ];
|
||||||
|
pkgs = import nixpkgs {
|
||||||
|
inherit system overlays;
|
||||||
|
};
|
||||||
|
|
||||||
|
rust = pkgs.rust-bin;
|
||||||
|
|
||||||
|
rustToolchain = rust.fromRustupToolchainFile ./rust-toolchain.toml;
|
||||||
|
rustNightlyToolchain = rust.selectLatestNightlyWith(tc: tc.minimal.override {
|
||||||
|
extensions = [ "rustfmt" ];
|
||||||
|
targets = [ "x86_64-unknown-linux-gnu" ];
|
||||||
|
}) ;
|
||||||
|
|
||||||
|
buildTools = [
|
||||||
|
rustToolchain
|
||||||
|
rustNightlyToolchain
|
||||||
|
];
|
||||||
|
|
||||||
|
devShell = pkgs.mkShell {
|
||||||
|
name = "@project_name@";
|
||||||
|
buildInputs = buildTools;
|
||||||
|
packages = with pkgs; [
|
||||||
|
rust-analyzer
|
||||||
|
];
|
||||||
|
};
|
||||||
|
in {
|
||||||
|
devShells.${system}.default = devShell;
|
||||||
|
};
|
||||||
|
}
|
5
templates/rust/crate-lib/rust-toolchain.toml
Normal file
5
templates/rust/crate-lib/rust-toolchain.toml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
[toolchain]
|
||||||
|
channel = "stable"
|
||||||
|
components = ["clippy", "rust-analyzer", "rust-src"]
|
||||||
|
targets = ["x86_64-unknown-linux-gnu"]
|
||||||
|
profile = "minimal" # includes rustc, cargo, and rust-std
|
18
templates/rust/crate-lib/rustfmt.toml
Normal file
18
templates/rust/crate-lib/rustfmt.toml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# Just enforce it here as well instead of relying on editorconfig alone
|
||||||
|
hard_tabs = false
|
||||||
|
tab_spaces = 4
|
||||||
|
newline_style = "Unix"
|
||||||
|
|
||||||
|
imports_granularity = "Module"
|
||||||
|
group_imports = "StdExternalCrate"
|
||||||
|
|
||||||
|
force_multiline_blocks = false
|
||||||
|
fn_single_line = false
|
||||||
|
comment_width = 100
|
||||||
|
wrap_comments = true
|
||||||
|
hex_literal_case = "Upper"
|
||||||
|
blank_lines_upper_bound = 2
|
||||||
|
overflow_delimited_expr = true
|
||||||
|
reorder_impl_items = true
|
0
templates/rust/crate-lib/src/lib.rs
Normal file
0
templates/rust/crate-lib/src/lib.rs
Normal file
Loading…
Reference in New Issue
Block a user