.github
.vscode
crates
nix
···
1
1
+
if ! has nix_direnv_version || ! nix_direnv_version 3.1.0; then
2
2
+
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.1.0/direnvrc" "sha256-yMJ2OVMzrFaDPn7q8nCBZFRYpL/f0RcHzhmw/i6btJM="
3
3
+
fi
4
4
+
5
5
+
watch_file \
6
6
+
rust-toolchain.toml \
7
7
+
nix/modules/*.nix
8
8
+
use flake
···
1
1
+
flake.lock linguist-generated=true
···
1
1
+
name: "CI Nix"
2
2
+
on:
3
3
+
# Run only when pushing to master branch, and making PRs
4
4
+
push:
5
5
+
branches:
6
6
+
- master
7
7
+
pull_request:
8
8
+
jobs:
9
9
+
build:
10
10
+
runs-on: ${{ matrix.os }}
11
11
+
strategy:
12
12
+
matrix:
13
13
+
os: [ubuntu-latest, macos-14]
14
14
+
steps:
15
15
+
- uses: actions/checkout@v4
16
16
+
- uses: nixbuild/nix-quick-install-action@v33
17
17
+
- name: Install omnix
18
18
+
run: nix --accept-flake-config profile install "github:juspay/omnix"
19
19
+
- run: om ci
···
1
1
+
on: [push]
2
2
+
3
3
+
name: CI
4
4
+
5
5
+
jobs:
6
6
+
check:
7
7
+
name: Rust project
8
8
+
runs-on: ubuntu-latest
9
9
+
steps:
10
10
+
- uses: actions/checkout@v2
11
11
+
- name: Install latest nightly
12
12
+
uses: actions-rs/toolchain@v1
13
13
+
with:
14
14
+
toolchain: nightly
15
15
+
override: true
16
16
+
components: rustfmt, clippy
17
17
+
18
18
+
# `cargo check` command here will use installed `nightly`
19
19
+
# as it is set as an "override" for current directory
20
20
+
21
21
+
- name: Run cargo check
22
22
+
uses: actions-rs/cargo@v1
23
23
+
with:
24
24
+
command: check
···
1
1
+
/target
2
2
+
/result
3
3
+
/result-lib
4
4
+
.direnv
5
5
+
6
6
+
/.pre-commit-config.yaml
···
1
1
+
{
2
2
+
"recommendations": [
3
3
+
"rust-lang.rust-analyzer",
4
4
+
"jnoortheen.nix-ide",
5
5
+
"mkhl.direnv",
6
6
+
"tamasfe.even-better-toml",
7
7
+
"fill-labs.dependi"
8
8
+
]
9
9
+
}
···
1
1
+
{
2
2
+
"editor.formatOnSave": true,
3
3
+
"rust-analyzer.files.excludeDirs": [
4
4
+
".direnv"
5
5
+
],
6
6
+
// https://twitter.com/sridca/status/1674947342607216641
7
7
+
// "editor.inlayHints.enabled": "offUnlessPressed",
8
8
+
}
···
1
1
+
# This file is automatically @generated by Cargo.
2
2
+
# It is not intended for manual editing.
3
3
+
version = 4
4
4
+
5
5
+
[[package]]
6
6
+
name = "anstream"
7
7
+
version = "0.6.20"
8
8
+
source = "registry+https://github.com/rust-lang/crates.io-index"
9
9
+
checksum = "3ae563653d1938f79b1ab1b5e668c87c76a9930414574a6583a7b7e11a8e6192"
10
10
+
dependencies = [
11
11
+
"anstyle",
12
12
+
"anstyle-parse",
13
13
+
"anstyle-query",
14
14
+
"anstyle-wincon",
15
15
+
"colorchoice",
16
16
+
"is_terminal_polyfill",
17
17
+
"utf8parse",
18
18
+
]
19
19
+
20
20
+
[[package]]
21
21
+
name = "anstyle"
22
22
+
version = "1.0.11"
23
23
+
source = "registry+https://github.com/rust-lang/crates.io-index"
24
24
+
checksum = "862ed96ca487e809f1c8e5a8447f6ee2cf102f846893800b20cebdf541fc6bbd"
25
25
+
26
26
+
[[package]]
27
27
+
name = "anstyle-parse"
28
28
+
version = "0.2.7"
29
29
+
source = "registry+https://github.com/rust-lang/crates.io-index"
30
30
+
checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2"
31
31
+
dependencies = [
32
32
+
"utf8parse",
33
33
+
]
34
34
+
35
35
+
[[package]]
36
36
+
name = "anstyle-query"
37
37
+
version = "1.1.4"
38
38
+
source = "registry+https://github.com/rust-lang/crates.io-index"
39
39
+
checksum = "9e231f6134f61b71076a3eab506c379d4f36122f2af15a9ff04415ea4c3339e2"
40
40
+
dependencies = [
41
41
+
"windows-sys",
42
42
+
]
43
43
+
44
44
+
[[package]]
45
45
+
name = "anstyle-wincon"
46
46
+
version = "3.0.10"
47
47
+
source = "registry+https://github.com/rust-lang/crates.io-index"
48
48
+
checksum = "3e0633414522a32ffaac8ac6cc8f748e090c5717661fddeea04219e2344f5f2a"
49
49
+
dependencies = [
50
50
+
"anstyle",
51
51
+
"once_cell_polyfill",
52
52
+
"windows-sys",
53
53
+
]
54
54
+
55
55
+
[[package]]
56
56
+
name = "clap"
57
57
+
version = "4.5.48"
58
58
+
source = "registry+https://github.com/rust-lang/crates.io-index"
59
59
+
checksum = "e2134bb3ea021b78629caa971416385309e0131b351b25e01dc16fb54e1b5fae"
60
60
+
dependencies = [
61
61
+
"clap_builder",
62
62
+
"clap_derive",
63
63
+
]
64
64
+
65
65
+
[[package]]
66
66
+
name = "clap_builder"
67
67
+
version = "4.5.48"
68
68
+
source = "registry+https://github.com/rust-lang/crates.io-index"
69
69
+
checksum = "c2ba64afa3c0a6df7fa517765e31314e983f51dda798ffba27b988194fb65dc9"
70
70
+
dependencies = [
71
71
+
"anstream",
72
72
+
"anstyle",
73
73
+
"clap_lex",
74
74
+
"strsim",
75
75
+
]
76
76
+
77
77
+
[[package]]
78
78
+
name = "clap_derive"
79
79
+
version = "4.5.47"
80
80
+
source = "registry+https://github.com/rust-lang/crates.io-index"
81
81
+
checksum = "bbfd7eae0b0f1a6e63d4b13c9c478de77c2eb546fba158ad50b4203dc24b9f9c"
82
82
+
dependencies = [
83
83
+
"heck",
84
84
+
"proc-macro2",
85
85
+
"quote",
86
86
+
"syn",
87
87
+
]
88
88
+
89
89
+
[[package]]
90
90
+
name = "clap_lex"
91
91
+
version = "0.7.5"
92
92
+
source = "registry+https://github.com/rust-lang/crates.io-index"
93
93
+
checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675"
94
94
+
95
95
+
[[package]]
96
96
+
name = "colorchoice"
97
97
+
version = "1.0.4"
98
98
+
source = "registry+https://github.com/rust-lang/crates.io-index"
99
99
+
checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75"
100
100
+
101
101
+
[[package]]
102
102
+
name = "heck"
103
103
+
version = "0.5.0"
104
104
+
source = "registry+https://github.com/rust-lang/crates.io-index"
105
105
+
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
106
106
+
107
107
+
[[package]]
108
108
+
name = "is_terminal_polyfill"
109
109
+
version = "1.70.1"
110
110
+
source = "registry+https://github.com/rust-lang/crates.io-index"
111
111
+
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
112
112
+
113
113
+
[[package]]
114
114
+
name = "jacquard"
115
115
+
version = "0.1.0"
116
116
+
dependencies = [
117
117
+
"clap",
118
118
+
]
119
119
+
120
120
+
[[package]]
121
121
+
name = "once_cell_polyfill"
122
122
+
version = "1.70.1"
123
123
+
source = "registry+https://github.com/rust-lang/crates.io-index"
124
124
+
checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad"
125
125
+
126
126
+
[[package]]
127
127
+
name = "proc-macro2"
128
128
+
version = "1.0.101"
129
129
+
source = "registry+https://github.com/rust-lang/crates.io-index"
130
130
+
checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de"
131
131
+
dependencies = [
132
132
+
"unicode-ident",
133
133
+
]
134
134
+
135
135
+
[[package]]
136
136
+
name = "quote"
137
137
+
version = "1.0.40"
138
138
+
source = "registry+https://github.com/rust-lang/crates.io-index"
139
139
+
checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
140
140
+
dependencies = [
141
141
+
"proc-macro2",
142
142
+
]
143
143
+
144
144
+
[[package]]
145
145
+
name = "strsim"
146
146
+
version = "0.11.1"
147
147
+
source = "registry+https://github.com/rust-lang/crates.io-index"
148
148
+
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
149
149
+
150
150
+
[[package]]
151
151
+
name = "syn"
152
152
+
version = "2.0.106"
153
153
+
source = "registry+https://github.com/rust-lang/crates.io-index"
154
154
+
checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6"
155
155
+
dependencies = [
156
156
+
"proc-macro2",
157
157
+
"quote",
158
158
+
"unicode-ident",
159
159
+
]
160
160
+
161
161
+
[[package]]
162
162
+
name = "unicode-ident"
163
163
+
version = "1.0.19"
164
164
+
source = "registry+https://github.com/rust-lang/crates.io-index"
165
165
+
checksum = "f63a545481291138910575129486daeaf8ac54aee4387fe7906919f7830c7d9d"
166
166
+
167
167
+
[[package]]
168
168
+
name = "utf8parse"
169
169
+
version = "0.2.2"
170
170
+
source = "registry+https://github.com/rust-lang/crates.io-index"
171
171
+
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
172
172
+
173
173
+
[[package]]
174
174
+
name = "windows-link"
175
175
+
version = "0.2.0"
176
176
+
source = "registry+https://github.com/rust-lang/crates.io-index"
177
177
+
checksum = "45e46c0661abb7180e7b9c281db115305d49ca1709ab8242adf09666d2173c65"
178
178
+
179
179
+
[[package]]
180
180
+
name = "windows-sys"
181
181
+
version = "0.60.2"
182
182
+
source = "registry+https://github.com/rust-lang/crates.io-index"
183
183
+
checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb"
184
184
+
dependencies = [
185
185
+
"windows-targets",
186
186
+
]
187
187
+
188
188
+
[[package]]
189
189
+
name = "windows-targets"
190
190
+
version = "0.53.4"
191
191
+
source = "registry+https://github.com/rust-lang/crates.io-index"
192
192
+
checksum = "2d42b7b7f66d2a06854650af09cfdf8713e427a439c97ad65a6375318033ac4b"
193
193
+
dependencies = [
194
194
+
"windows-link",
195
195
+
"windows_aarch64_gnullvm",
196
196
+
"windows_aarch64_msvc",
197
197
+
"windows_i686_gnu",
198
198
+
"windows_i686_gnullvm",
199
199
+
"windows_i686_msvc",
200
200
+
"windows_x86_64_gnu",
201
201
+
"windows_x86_64_gnullvm",
202
202
+
"windows_x86_64_msvc",
203
203
+
]
204
204
+
205
205
+
[[package]]
206
206
+
name = "windows_aarch64_gnullvm"
207
207
+
version = "0.53.0"
208
208
+
source = "registry+https://github.com/rust-lang/crates.io-index"
209
209
+
checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764"
210
210
+
211
211
+
[[package]]
212
212
+
name = "windows_aarch64_msvc"
213
213
+
version = "0.53.0"
214
214
+
source = "registry+https://github.com/rust-lang/crates.io-index"
215
215
+
checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c"
216
216
+
217
217
+
[[package]]
218
218
+
name = "windows_i686_gnu"
219
219
+
version = "0.53.0"
220
220
+
source = "registry+https://github.com/rust-lang/crates.io-index"
221
221
+
checksum = "c1dc67659d35f387f5f6c479dc4e28f1d4bb90ddd1a5d3da2e5d97b42d6272c3"
222
222
+
223
223
+
[[package]]
224
224
+
name = "windows_i686_gnullvm"
225
225
+
version = "0.53.0"
226
226
+
source = "registry+https://github.com/rust-lang/crates.io-index"
227
227
+
checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11"
228
228
+
229
229
+
[[package]]
230
230
+
name = "windows_i686_msvc"
231
231
+
version = "0.53.0"
232
232
+
source = "registry+https://github.com/rust-lang/crates.io-index"
233
233
+
checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d"
234
234
+
235
235
+
[[package]]
236
236
+
name = "windows_x86_64_gnu"
237
237
+
version = "0.53.0"
238
238
+
source = "registry+https://github.com/rust-lang/crates.io-index"
239
239
+
checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba"
240
240
+
241
241
+
[[package]]
242
242
+
name = "windows_x86_64_gnullvm"
243
243
+
version = "0.53.0"
244
244
+
source = "registry+https://github.com/rust-lang/crates.io-index"
245
245
+
checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57"
246
246
+
247
247
+
[[package]]
248
248
+
name = "windows_x86_64_msvc"
249
249
+
version = "0.53.0"
250
250
+
source = "registry+https://github.com/rust-lang/crates.io-index"
251
251
+
checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486"
···
1
1
+
[workspace]
2
2
+
resolver = "2"
3
3
+
members = ["crates/*"]
4
4
+
5
5
+
6
6
+
[workspace.package]
7
7
+
authors = ["Orual <orual@nonbinary.computer>"]
8
8
+
edition = "2024"
9
9
+
description = "A simple Rust project using Nix"
10
10
+
version = "0.1.0"
11
11
+
12
12
+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
13
13
+
14
14
+
[workspace.dependencies]
15
15
+
clap = { version = "4.5", features = ["derive"] }
···
1
1
+
MIT License
2
2
+
3
3
+
Copyright (c) 2023 Orual
4
4
+
5
5
+
Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
+
of this software and associated documentation files (the "Software"), to deal
7
7
+
in the Software without restriction, including without limitation the rights
8
8
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
9
+
copies of the Software, and to permit persons to whom the Software is
10
10
+
furnished to do so, subject to the following conditions:
11
11
+
12
12
+
The above copyright notice and this permission notice shall be included in all
13
13
+
copies or substantial portions of the Software.
14
14
+
15
15
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
16
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
17
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
18
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
+
SOFTWARE.
···
1
1
+
A template Rust project with fully functional and no-frills Nix support, as well as builtin VSCode configuration to get IDE experience without any manual setup (just [install direnv](https://nixos.asia/en/direnv), open in VSCode and accept the suggestions). It uses [crane](https://crane.dev/), via [rust-flake](https://github.com/juspay/rust-flake).
2
2
+
3
3
+
> [!NOTE]
4
4
+
> If you are looking for the original template based on [this blog post](https://srid.ca/rust-nix)'s use of `crate2nix`, browse from [this tag](https://github.com/srid/jacquard/tree/crate2nix). The evolution of this template can be gleaned from [releases](https://github.com/srid/jacquard/releases).
5
5
+
6
6
+
## Usage
7
7
+
8
8
+
You can use [omnix](https://omnix.page/om/init.html)[^omnix] to initialize this template:
9
9
+
```
10
10
+
nix run nixpkgs#omnix -- init github:srid/jacquard -o ~/my-rust-project
11
11
+
```
12
12
+
13
13
+
[^omnix]: If initializing manually, make sure to:
14
14
+
- Change `name` in Cargo.toml.
15
15
+
- Run `cargo generate-lockfile` in the nix shelld
16
16
+
17
17
+
## Adapting this template
18
18
+
19
19
+
- There are two CI workflows, and one of them uses Nix which is slower (unless you configure a cache) than the other one based on rustup. Pick one or the other depending on your trade-offs.
20
20
+
21
21
+
## Development (Flakes)
22
22
+
23
23
+
This repo uses [Flakes](https://nixos.asia/en/flakes) from the get-go.
24
24
+
25
25
+
```bash
26
26
+
# Dev shell
27
27
+
nix develop
28
28
+
29
29
+
# or run via cargo
30
30
+
nix develop -c cargo run
31
31
+
32
32
+
# build
33
33
+
nix build
34
34
+
```
35
35
+
36
36
+
We also provide a [`justfile`](https://just.systems/) for Makefile'esque commands to be run inside of the devShell.
37
37
+
38
38
+
## Tips
39
39
+
40
40
+
- Run `nix flake update` to update all flake inputs.
41
41
+
- Run `nix --accept-flake-config run github:juspay/omnix ci` to build _all_ outputs.
42
42
+
- [pre-commit] hooks will automatically be setup in Nix shell. You can also run `pre-commit run -a` manually to run the hooks (e.g.: to autoformat the project tree using `rustfmt`, `nixpkgs-fmt`, etc.).
43
43
+
44
44
+
## Discussion
45
45
+
46
46
+
- [Zulip](https://nixos.zulipchat.com/#narrow/stream/413950-nix)
47
47
+
48
48
+
## See Also
49
49
+
50
50
+
- [nixos.wiki: Packaging Rust projects with nix](https://nixos.wiki/wiki/Rust#Packaging_Rust_projects_with_nix)
···
1
1
+
[package]
2
2
+
authors.workspace = true
3
3
+
# If you change the name here, you must also do it in flake.nix (and run `cargo generate-lockfile` afterwards)
4
4
+
name = "jacquard"
5
5
+
description = "A simple Rust project using Nix"
6
6
+
version.workspace = true
7
7
+
8
8
+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
9
9
+
10
10
+
[dependencies]
11
11
+
clap = { workspace = true }
···
1
1
+
use clap::Parser;
2
2
+
3
3
+
#[derive(Parser, Debug)]
4
4
+
#[command(author = "Orual", version, about)]
5
5
+
/// Application configuration
6
6
+
struct Args {
7
7
+
/// whether to be verbose
8
8
+
#[arg(short = 'v')]
9
9
+
verbose: bool,
10
10
+
11
11
+
/// an optional name to greet
12
12
+
#[arg()]
13
13
+
name: Option<String>,
14
14
+
}
15
15
+
16
16
+
fn main() {
17
17
+
let args = Args::parse();
18
18
+
if args.verbose {
19
19
+
println!("DEBUG {args:?}");
20
20
+
}
21
21
+
println!(
22
22
+
"Hello {} (from jacquard)!",
23
23
+
args.name.unwrap_or("world".to_string())
24
24
+
);
25
25
+
}
···
1
1
+
{
2
2
+
"nodes": {
3
3
+
"cargo-doc-live": {
4
4
+
"locked": {
5
5
+
"lastModified": 1724704668,
6
6
+
"narHash": "sha256-kJFYXlWUodg5WhJ0NuvrP0mCvOT/2AOIo8oGeYLXocs=",
7
7
+
"owner": "srid",
8
8
+
"repo": "cargo-doc-live",
9
9
+
"rev": "b09d5d258d2498829e03014931fc19aed499b86f",
10
10
+
"type": "github"
11
11
+
},
12
12
+
"original": {
13
13
+
"owner": "srid",
14
14
+
"repo": "cargo-doc-live",
15
15
+
"type": "github"
16
16
+
}
17
17
+
},
18
18
+
"crane": {
19
19
+
"locked": {
20
20
+
"lastModified": 1736566337,
21
21
+
"narHash": "sha256-SC0eDcZPqISVt6R0UfGPyQLrI0+BppjjtQ3wcSlk0oI=",
22
22
+
"owner": "ipetkov",
23
23
+
"repo": "crane",
24
24
+
"rev": "9172acc1ee6c7e1cbafc3044ff850c568c75a5a3",
25
25
+
"type": "github"
26
26
+
},
27
27
+
"original": {
28
28
+
"owner": "ipetkov",
29
29
+
"repo": "crane",
30
30
+
"type": "github"
31
31
+
}
32
32
+
},
33
33
+
"flake-parts": {
34
34
+
"inputs": {
35
35
+
"nixpkgs-lib": [
36
36
+
"nixpkgs"
37
37
+
]
38
38
+
},
39
39
+
"locked": {
40
40
+
"lastModified": 1725234343,
41
41
+
"narHash": "sha256-+ebgonl3NbiKD2UD0x4BszCZQ6sTfL4xioaM49o5B3Y=",
42
42
+
"owner": "hercules-ci",
43
43
+
"repo": "flake-parts",
44
44
+
"rev": "567b938d64d4b4112ee253b9274472dc3a346eb6",
45
45
+
"type": "github"
46
46
+
},
47
47
+
"original": {
48
48
+
"owner": "hercules-ci",
49
49
+
"repo": "flake-parts",
50
50
+
"type": "github"
51
51
+
}
52
52
+
},
53
53
+
"git-hooks": {
54
54
+
"flake": false,
55
55
+
"locked": {
56
56
+
"lastModified": 1734425854,
57
57
+
"narHash": "sha256-nzE5UbJ41aPEKf8R2ZFYtLkqPmF7EIUbNEdHMBLg0Ig=",
58
58
+
"owner": "cachix",
59
59
+
"repo": "git-hooks.nix",
60
60
+
"rev": "0ddd26d0925f618c3a5d85a4fa5eb1e23a09491d",
61
61
+
"type": "github"
62
62
+
},
63
63
+
"original": {
64
64
+
"owner": "cachix",
65
65
+
"repo": "git-hooks.nix",
66
66
+
"type": "github"
67
67
+
}
68
68
+
},
69
69
+
"nixpkgs": {
70
70
+
"locked": {
71
71
+
"lastModified": 1736693123,
72
72
+
"narHash": "sha256-9lIfXCaBPwUA7FnfDnoH4gxxdOvXG78k6UlUw0+ZDxc=",
73
73
+
"owner": "nixos",
74
74
+
"repo": "nixpkgs",
75
75
+
"rev": "2fdec2c2e68b7b7845d1ea4e0894c63143e3261b",
76
76
+
"type": "github"
77
77
+
},
78
78
+
"original": {
79
79
+
"owner": "nixos",
80
80
+
"ref": "nixpkgs-unstable",
81
81
+
"repo": "nixpkgs",
82
82
+
"type": "github"
83
83
+
}
84
84
+
},
85
85
+
"process-compose-flake": {
86
86
+
"locked": {
87
87
+
"lastModified": 1724606023,
88
88
+
"narHash": "sha256-rdGeNa/lCS8E1lXzPqgl+vZUUvnbEZT11Bqkx5jfYug=",
89
89
+
"owner": "Platonic-Systems",
90
90
+
"repo": "process-compose-flake",
91
91
+
"rev": "f6ce9481df9aec739e4e06b67492401a5bb4f0b1",
92
92
+
"type": "github"
93
93
+
},
94
94
+
"original": {
95
95
+
"owner": "Platonic-Systems",
96
96
+
"repo": "process-compose-flake",
97
97
+
"type": "github"
98
98
+
}
99
99
+
},
100
100
+
"root": {
101
101
+
"inputs": {
102
102
+
"cargo-doc-live": "cargo-doc-live",
103
103
+
"flake-parts": "flake-parts",
104
104
+
"git-hooks": "git-hooks",
105
105
+
"nixpkgs": "nixpkgs",
106
106
+
"process-compose-flake": "process-compose-flake",
107
107
+
"rust-flake": "rust-flake",
108
108
+
"systems": "systems"
109
109
+
}
110
110
+
},
111
111
+
"rust-flake": {
112
112
+
"inputs": {
113
113
+
"crane": "crane",
114
114
+
"nixpkgs": [
115
115
+
"nixpkgs"
116
116
+
],
117
117
+
"rust-overlay": "rust-overlay"
118
118
+
},
119
119
+
"locked": {
120
120
+
"lastModified": 1736806612,
121
121
+
"narHash": "sha256-WioA+Vk7suDK+Ek77rDlbuxV6WqwFt30JsKHrmDCSiU=",
122
122
+
"owner": "juspay",
123
123
+
"repo": "rust-flake",
124
124
+
"rev": "b5f39885e2fcf137bfaf75decc077f9cca2bd984",
125
125
+
"type": "github"
126
126
+
},
127
127
+
"original": {
128
128
+
"owner": "juspay",
129
129
+
"repo": "rust-flake",
130
130
+
"type": "github"
131
131
+
}
132
132
+
},
133
133
+
"rust-overlay": {
134
134
+
"inputs": {
135
135
+
"nixpkgs": [
136
136
+
"rust-flake",
137
137
+
"nixpkgs"
138
138
+
]
139
139
+
},
140
140
+
"locked": {
141
141
+
"lastModified": 1736700680,
142
142
+
"narHash": "sha256-9gmWIb8xsycWHEYpd2SiVIAZnUULX6Y+IMMZBcDUCQU=",
143
143
+
"owner": "oxalica",
144
144
+
"repo": "rust-overlay",
145
145
+
"rev": "5d1865c0da63b4c949f383d982b6b43519946e8f",
146
146
+
"type": "github"
147
147
+
},
148
148
+
"original": {
149
149
+
"owner": "oxalica",
150
150
+
"repo": "rust-overlay",
151
151
+
"type": "github"
152
152
+
}
153
153
+
},
154
154
+
"systems": {
155
155
+
"locked": {
156
156
+
"lastModified": 1681028828,
157
157
+
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
158
158
+
"owner": "nix-systems",
159
159
+
"repo": "default",
160
160
+
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
161
161
+
"type": "github"
162
162
+
},
163
163
+
"original": {
164
164
+
"owner": "nix-systems",
165
165
+
"repo": "default",
166
166
+
"type": "github"
167
167
+
}
168
168
+
}
169
169
+
},
170
170
+
"root": "root",
171
171
+
"version": 7
172
172
+
}
···
1
1
+
{
2
2
+
inputs = {
3
3
+
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
4
4
+
flake-parts.url = "github:hercules-ci/flake-parts";
5
5
+
flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs";
6
6
+
systems.url = "github:nix-systems/default";
7
7
+
rust-flake.url = "github:juspay/rust-flake";
8
8
+
rust-flake.inputs.nixpkgs.follows = "nixpkgs";
9
9
+
process-compose-flake.url = "github:Platonic-Systems/process-compose-flake";
10
10
+
cargo-doc-live.url = "github:srid/cargo-doc-live";
11
11
+
12
12
+
git-hooks.url = "github:cachix/git-hooks.nix";
13
13
+
git-hooks.flake = false;
14
14
+
};
15
15
+
16
16
+
outputs = inputs:
17
17
+
inputs.flake-parts.lib.mkFlake {inherit inputs;} {
18
18
+
systems = import inputs.systems;
19
19
+
20
20
+
# See ./nix/modules/*.nix for the modules that are imported here.
21
21
+
imports = with builtins;
22
22
+
map
23
23
+
(fn: ./nix/modules/${fn})
24
24
+
(attrNames (readDir ./nix/modules));
25
25
+
};
26
26
+
}
···
1
1
+
default:
2
2
+
@just --list
3
3
+
4
4
+
# Run pre-commit hooks on all files, including autoformatting
5
5
+
pre-commit-all:
6
6
+
pre-commit run --all-files
7
7
+
8
8
+
# Run 'cargo run' on the project
9
9
+
run *ARGS:
10
10
+
cargo run {{ARGS}}
11
11
+
12
12
+
# Run 'bacon' to run the project (auto-recompiles)
13
13
+
watch *ARGS:
14
14
+
bacon --job run -- -- {{ ARGS }}
···
1
1
+
{inputs, ...}: {
2
2
+
perSystem = {
3
3
+
config,
4
4
+
self',
5
5
+
pkgs,
6
6
+
lib,
7
7
+
...
8
8
+
}: {
9
9
+
devShells.default = pkgs.mkShell {
10
10
+
name = "jacquard-shell";
11
11
+
inputsFrom = [
12
12
+
self'.devShells.rust
13
13
+
config.pre-commit.devShell # See ./nix/modules/pre-commit.nix
14
14
+
];
15
15
+
packages = with pkgs; [
16
16
+
just
17
17
+
nixd # Nix language server
18
18
+
bacon
19
19
+
rust-analyzer
20
20
+
];
21
21
+
};
22
22
+
};
23
23
+
}
···
1
1
+
{ inputs, ... }:
2
2
+
{
3
3
+
imports = [
4
4
+
(inputs.git-hooks + /flake-module.nix)
5
5
+
];
6
6
+
perSystem = { config, self', pkgs, lib, ... }: {
7
7
+
pre-commit.settings = {
8
8
+
hooks = {
9
9
+
nixpkgs-fmt.enable = true;
10
10
+
rustfmt.enable = true;
11
11
+
};
12
12
+
};
13
13
+
};
14
14
+
}
···
1
1
+
{inputs, ...}: {
2
2
+
imports = [
3
3
+
inputs.rust-flake.flakeModules.default
4
4
+
inputs.rust-flake.flakeModules.nixpkgs
5
5
+
# inputs.process-compose-flake.flakeModule
6
6
+
# inputs.cargo-doc-live.flakeModule
7
7
+
];
8
8
+
perSystem = {
9
9
+
config,
10
10
+
self',
11
11
+
pkgs,
12
12
+
lib,
13
13
+
...
14
14
+
}: let
15
15
+
inherit (pkgs.stdenv) isDarwin;
16
16
+
inherit (pkgs.darwin) apple_sdk;
17
17
+
18
18
+
# Common configuration for all crates
19
19
+
globalCrateConfig = {
20
20
+
crane.clippy.enable = false;
21
21
+
};
22
22
+
23
23
+
# Common build inputs for all crates
24
24
+
commonBuildInputs = lib.optionals isDarwin (
25
25
+
with apple_sdk.frameworks; [
26
26
+
IOKit
27
27
+
Security
28
28
+
SystemConfiguration
29
29
+
]
30
30
+
);
31
31
+
in {
32
32
+
rust-project = {
33
33
+
# Source filtering to avoid unnecessary rebuilds
34
34
+
src = lib.cleanSourceWith {
35
35
+
src = inputs.self;
36
36
+
filter = config.rust-project.crane-lib.filterCargoSources;
37
37
+
};
38
38
+
crates = {
39
39
+
"jacquard" = {
40
40
+
imports = [globalCrateConfig];
41
41
+
autoWire = ["crate" "clippy"];
42
42
+
path = ./../../crates/jacquard;
43
43
+
crane = {
44
44
+
args = {
45
45
+
buildInputs = commonBuildInputs;
46
46
+
};
47
47
+
};
48
48
+
};
49
49
+
};
50
50
+
};
51
51
+
packages.default = self'.packages.jacquard;
52
52
+
};
53
53
+
}
···
1
1
+
{ inputs, ... }:
2
2
+
3
3
+
{
4
4
+
flake = rec {
5
5
+
templates.default = {
6
6
+
description = "A batteries-included Rust project template for Nix";
7
7
+
path = builtins.path { path = inputs.self; };
8
8
+
};
9
9
+
10
10
+
# https://omnix.page/om/init.html#spec
11
11
+
om.templates.jacquard = {
12
12
+
template = templates.default;
13
13
+
params = [
14
14
+
{
15
15
+
name = "package-name";
16
16
+
description = "Name of the Rust package";
17
17
+
placeholder = "jacquard";
18
18
+
}
19
19
+
{
20
20
+
name = "author";
21
21
+
description = "Author name";
22
22
+
placeholder = "Orual";
23
23
+
}
24
24
+
{
25
25
+
name = "author-email";
26
26
+
description = "Author email";
27
27
+
placeholder = "orual@nonbinary.computer";
28
28
+
}
29
29
+
{
30
30
+
name = "vscode";
31
31
+
description = "Include the VSCode settings folder (./.vscode)";
32
32
+
paths = [ ".vscode" ];
33
33
+
value = true;
34
34
+
}
35
35
+
{
36
36
+
name = "github-ci";
37
37
+
description = "Include GitHub Actions workflow configuration";
38
38
+
paths = [ ".github" ];
39
39
+
value = true;
40
40
+
}
41
41
+
{
42
42
+
name = "nix-template";
43
43
+
description = "Keep the flake template in the project";
44
44
+
paths = [ "**/template.nix" ];
45
45
+
value = false;
46
46
+
}
47
47
+
];
48
48
+
tests = {
49
49
+
default = {
50
50
+
params = {
51
51
+
package-name = "qux";
52
52
+
author = "John";
53
53
+
author-email = "john@example.com";
54
54
+
};
55
55
+
asserts = {
56
56
+
source = {
57
57
+
"Cargo.toml" = true;
58
58
+
"flake.nix" = true;
59
59
+
".github/workflows/ci.yml" = true;
60
60
+
".vscode" = true;
61
61
+
"nix/modules/template.nix" = false;
62
62
+
};
63
63
+
packages.default = {
64
64
+
"bin/qux" = true;
65
65
+
};
66
66
+
};
67
67
+
};
68
68
+
};
69
69
+
};
70
70
+
};
71
71
+
}
···
1
1
+
[toolchain]
2
2
+
channel = "stable"