Add template for rust library crate

This commit is contained in:
Patrick Auernig 2024-09-29 14:38:28 +02:00
parent f64c01ab6f
commit 4c7de9b72c
8 changed files with 82 additions and 0 deletions

View 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

View File

@ -0,0 +1 @@
use flake

2
templates/rust/crate-lib/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/target
.envrc

View File

View 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;
};
}

View 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

View 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

View File