Add rust workspace template
This commit is contained in:
commit
f64c01ab6f
12
flake.nix
Normal file
12
flake.nix
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
description = "Various project templates";
|
||||
|
||||
outputs = { nixpkgs, ... }: {
|
||||
templates = {
|
||||
rust-workspace = {
|
||||
path = ./templates/rust/workspace;
|
||||
description = "Cargo based rust project using a virtual workspace";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
12
templates/rust/workspace/.editorconfig
Normal file
12
templates/rust/workspace/.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/workspace/.envrc
Normal file
1
templates/rust/workspace/.envrc
Normal file
@ -0,0 +1 @@
|
||||
use flake
|
2
templates/rust/workspace/.gitignore
vendored
Normal file
2
templates/rust/workspace/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/target
|
||||
.envrc
|
15
templates/rust/workspace/Cargo.toml
Normal file
15
templates/rust/workspace/Cargo.toml
Normal file
@ -0,0 +1,15 @@
|
||||
[workspace]
|
||||
resolver = "2"
|
||||
members = [
|
||||
"./crates/mylib",
|
||||
]
|
||||
|
||||
|
||||
[workspace.package]
|
||||
edition = "2021"
|
||||
version = "0.1.0"
|
||||
# license-file = "LICENSE"
|
||||
# authors = []
|
||||
|
||||
|
||||
[workspace.dependencies]
|
14
templates/rust/workspace/crates/mylib/Cargo.toml
Normal file
14
templates/rust/workspace/crates/mylib/Cargo.toml
Normal file
@ -0,0 +1,14 @@
|
||||
[package]
|
||||
name = "mylib"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
# license.workspace = true
|
||||
# authors.workspace = true
|
||||
publish = false
|
||||
|
||||
|
||||
[features]
|
||||
default = []
|
||||
|
||||
|
||||
[dependencies]
|
0
templates/rust/workspace/crates/mylib/src/lib.rs
Normal file
0
templates/rust/workspace/crates/mylib/src/lib.rs
Normal file
38
templates/rust/workspace/flake.nix
Normal file
38
templates/rust/workspace/flake.nix
Normal file
@ -0,0 +1,38 @@
|
||||
{
|
||||
description = "@project_description@";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
rust-overlay.url = "github:oxalica/rust-overlay";
|
||||
};
|
||||
|
||||
outputs = { nixpkgs, rust-overlay, ... }:
|
||||
let
|
||||
system = "x86_64-linux";
|
||||
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [ (import rust-overlay) ];
|
||||
};
|
||||
|
||||
rustToolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
|
||||
rustNightlyToolchain = pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.minimal.override {
|
||||
extensions = [ "rustfmt" ];
|
||||
targets = [ "x86_64-unknown-linux-gnu" ];
|
||||
});
|
||||
|
||||
|
||||
buildTools = with pkgs; [
|
||||
rustToolchain
|
||||
rustNightlyToolchain
|
||||
pkg-config
|
||||
];
|
||||
|
||||
devShell = pkgs.mkShell {
|
||||
name = "@project_name@";
|
||||
buildInputs = buildTools;
|
||||
};
|
||||
in {
|
||||
devShells.${system}.default = devShell;
|
||||
};
|
||||
}
|
5
templates/rust/workspace/rust-toolchain.toml
Normal file
5
templates/rust/workspace/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/workspace/rustfmt.toml
Normal file
18
templates/rust/workspace/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
|
Loading…
Reference in New Issue
Block a user