File tree 4 files changed +74
-3
lines changed
4 files changed +74
-3
lines changed Original file line number Diff line number Diff line change
1
+ use flake
Original file line number Diff line number Diff line change 1
1
/target
2
+ result
3
+ Cargo.lock
Original file line number Diff line number Diff line change 1
- Template to be used with [ cargo-generate] ( https://crates.io/crates/cargo-generate ) .
1
+ # Eddie's Rust Template
2
+ Minimal template for Rust projects to be used with Nix developement environments.
2
3
3
- Differences to ` cargo new ` :
4
- - My preferred ` rustfmt.toml `
4
+ ### Requirements
5
+ - Flakes-enabled installation of [ Nix] ( https://nixos.org/download/ )
6
+ - [ cargo-generate] ( https://crates.io/crates/cargo-generate )
7
+
8
+ ### Installation
9
+ ``` shell
10
+ cargo generate eddien24/rust-template
11
+ ```
12
+
13
+ ### Usage
14
+ - ` nix develop ` : start developement shell. Will create ` flake.lock ` the first time it is run.
15
+ - ` nix build ` : build project
16
+ - ` nix run ` : run project
17
+
18
+ Modified from [ MordragT/nix-templates] ( https://github.com/MordragT/nix-templates/tree/master/rust-stable ) .
Original file line number Diff line number Diff line change
1
+ {
2
+ description = "Rust development template" ;
3
+
4
+ inputs = {
5
+ utils . url = "github:numtide/flake-utils" ;
6
+ } ;
7
+
8
+ outputs = {
9
+ self ,
10
+ nixpkgs ,
11
+ utils ,
12
+ ...
13
+ } @inputs :
14
+ utils . lib . eachDefaultSystem
15
+ (
16
+ system : let
17
+ pkgs = import nixpkgs { inherit system ; } ;
18
+ toolchain = pkgs . rustPlatform ;
19
+ in rec
20
+ {
21
+ # Executed by `nix build`
22
+ packages . default = toolchain . buildRustPackage {
23
+ pname = "template" ;
24
+ version = "0.1.0" ;
25
+ src = ./. ;
26
+ cargoLock . lockFile = ./Cargo.lock ;
27
+
28
+ # For other makeRustPlatform features see:
29
+ # https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks/rust.section.md#cargo-features-cargo-features
30
+ } ;
31
+
32
+ # Executed by `nix run`
33
+ apps . default = utils . lib . mkApp { drv = packages . default ; } ;
34
+
35
+ # Used by `nix develop`
36
+ devShells . default = pkgs . mkShell {
37
+ buildInputs = with pkgs ; [
38
+ ( with toolchain ; [
39
+ cargo
40
+ rustc
41
+ rustLibSrc
42
+ ] )
43
+ clippy
44
+ rustfmt
45
+ pkg-config
46
+ rust-analyzer
47
+ ] ;
48
+
49
+ # Specify the rust-src path (many editors rely on this)
50
+ RUST_SRC_PATH = "${ toolchain . rustLibSrc } " ;
51
+ } ;
52
+ }
53
+ ) ;
54
+ }
You can’t perform that action at this time.
0 commit comments