Skip to content

Commit 6c6c269

Browse files
committed
template: rust
1 parent dbd3ae6 commit 6c6c269

File tree

5 files changed

+86
-0
lines changed

5 files changed

+86
-0
lines changed

templates/rust/.envrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use flake

templates/rust/.gitignore

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Nix
2+
**/.direnv/
3+
**/result/
4+
**/result-*/
5+
6+
# Editor
7+
**/.idea/
8+
**/.vscode/
9+
10+
# Rust
11+
**/target/
12+
**/debug/
13+
**/*.rs.bk
14+
**/*.pdb

templates/rust/flake.nix

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
inputs = {
3+
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
4+
flake-utils.url = "github:numtide/flake-utils";
5+
};
6+
7+
outputs =
8+
{ self
9+
, nixpkgs
10+
, flake-utils
11+
}: flake-utils.lib.eachDefaultSystem (system:
12+
let
13+
pkgs = import nixpkgs { inherit system; };
14+
in
15+
{
16+
packages.default = pkgs.rustPlatform.buildRustPackage {
17+
pname = "<NAME>";
18+
inherit ((pkgs.lib.importTOML ./Cargo.toml).package) version;
19+
src = ./.;
20+
cargoLock.lockFile = ./Cargo.lock;
21+
};
22+
23+
apps.default = flake-utils.lib.mkApp {
24+
drv = self.packages.${system}.default;
25+
};
26+
27+
devShells.default = pkgs.mkShell {
28+
packages = with pkgs; [
29+
cargo
30+
rustc
31+
rustfmt
32+
];
33+
};
34+
35+
formatter = pkgs.writeShellScriptBin "formatter" ''
36+
set -eoux pipefail
37+
shopt -s globstar
38+
${pkgs.nixpkgs-fmt}/bin/nixpkgs-fmt .
39+
${pkgs.rustfmt}/bin/rustfmt **/*.rs
40+
'';
41+
});
42+
}

templates/rust/license.txt

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Yifei Sun
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

templates/rust/readme.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# <NAME>
2+
3+
[![Built with Nix](https://builtwithnix.org/badge.svg)](https://builtwithnix.org)
4+
5+
## License
6+
7+
The contents inside this repository, excluding all submodules, are licensed under the [MIT License](license.txt).
8+
Third-party file(s) and/or code(s) are subject to their original term(s) and/or license(s).

0 commit comments

Comments
 (0)