├── .editorconfig ├── .envrc ├── .github └── workflows │ ├── nix.yml │ └── no-nix.yml ├── .gitignore ├── Cargo.lock ├── Cargo.toml ├── LICENSE ├── README.md ├── deny.toml ├── flake.lock ├── flake.nix ├── rust-toolchain.toml ├── rustfmt.toml └── src └── main.rs /.editorconfig: -------------------------------------------------------------------------------- 1 | # https://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | max_line_length = 100 12 | 13 | [*.rs] 14 | indent_style = space 15 | indent_size = 4 16 | -------------------------------------------------------------------------------- /.envrc: -------------------------------------------------------------------------------- 1 | use flake 2 | -------------------------------------------------------------------------------- /.github/workflows/nix.yml: -------------------------------------------------------------------------------- 1 | # Our desired pipeline using only a Nix shell environment 2 | name: Check and build the TODOs API (Nix) 3 | 4 | on: 5 | push: 6 | branches: 7 | - main 8 | tags: 9 | - "v*.*.*" 10 | pull_request: 11 | branches: 12 | - main 13 | 14 | jobs: 15 | check_nix: 16 | name: Check TODOs API 17 | runs-on: ubuntu-22.04 18 | steps: 19 | - name: git checkout 20 | uses: actions/checkout@v3 21 | - name: Install Nix 22 | uses: DeterminateSystems/nix-installer-action@main 23 | - uses: DeterminateSystems/magic-nix-cache-action@main 24 | - name: Check Nixpkgs inputs 25 | uses: DeterminateSystems/flake-checker-action@main 26 | with: 27 | fail-mode: true 28 | 29 | # Nix-specific logic begins here 30 | - name: Check Rust formatting 31 | run: | 32 | nix develop --command \ 33 | cargo fmt --check 34 | - name: Audit Rust code 35 | run: | 36 | nix develop --command \ 37 | cargo-deny check 38 | - name: editorconfig check 39 | run: | 40 | nix develop --command \ 41 | eclint \ 42 | -exclude "Cargo.lock" 43 | - name: Check spelling 44 | run: | 45 | nix develop --command \ 46 | codespell \ 47 | --skip target,.git \ 48 | --ignore-words-list crate 49 | 50 | build_and_test_nix: 51 | name: Test and build TODOs API 52 | needs: check_nix 53 | strategy: 54 | matrix: 55 | os: [ubuntu-22.04, macos-12] 56 | runs-on: ubuntu-22.04 57 | steps: 58 | - name: git checkout 59 | uses: actions/checkout@v3 60 | - name: Install Nix 61 | uses: DeterminateSystems/nix-installer-action@main 62 | - uses: DeterminateSystems/magic-nix-cache-action@main 63 | - name: Set up Rust cache 64 | uses: actions/cache@v3 65 | with: 66 | path: | 67 | ~/.cargo/bin/ 68 | ~/.cargo/registry/index/ 69 | ~/.cargo/registry/cache/ 70 | ~/.cargo/git/db/ 71 | target/ 72 | key: todos-app-${{ hashFiles('**/Cargo.lock') }} 73 | - name: Test TODOs API 74 | run: | 75 | nix develop --command \ 76 | cargo test 77 | - name: Build TODOs API 78 | # nix build would also work here because `todos` is the default package 79 | run: nix build .#todos 80 | 81 | # I don't talk about this in the blog post so consider it an Easter egg. 82 | # You can indeed use Nix to build Docker containers without any need for 83 | # a Dockerfile. For more info, see: 84 | # https://nix.dev/tutorials/building-and-running-docker-images 85 | # https://github.com/the-nix-way/nix-docker-examples/ 86 | # https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/docker/examples.nix 87 | - name: Build TODOs Docker image 88 | run: nix build .#docker 89 | -------------------------------------------------------------------------------- /.github/workflows/no-nix.yml: -------------------------------------------------------------------------------- 1 | # Our desired pipeline using only third-party Actions 2 | name: Check and build the TODOs API (no Nix) 3 | 4 | on: 5 | push: 6 | branches: 7 | - main 8 | tags: 9 | - "v*.*.*" 10 | pull_request: 11 | branches: 12 | - main 13 | 14 | jobs: 15 | check_no-nix: 16 | name: Check TODOs API 17 | runs-on: ubuntu-22.04 18 | steps: 19 | - name: git checkout 20 | uses: actions/checkout@v3 21 | 22 | # Third-party Actions 23 | - name: Set up Rust toolchain 24 | uses: actions-rs/toolchain@v1 25 | with: 26 | # Required because this Action recognizes rust-toolchain 27 | # but not rust-toolchain.toml 28 | toolchain: "1.63.0" 29 | profile: minimal 30 | components: clippy, rustfmt 31 | - name: Check Rust formatting 32 | uses: actions-rs/cargo@v1 33 | with: 34 | command: fmt 35 | args: --check --all 36 | - name: Audit Rust code 37 | uses: EmbarkStudios/cargo-deny-action@v1 38 | with: 39 | command: check 40 | - name: editorconfig check 41 | uses: reviewdog/action-eclint@v1 42 | with: 43 | eclint_flags: -exclude "Cargo.lock" 44 | - name: Check spelling 45 | uses: codespell-project/actions-codespell@master 46 | with: 47 | skip: target 48 | ignore_words_list: crate 49 | 50 | build_and_test_no-nix: 51 | name: Test and build TODOs API 52 | needs: check_no-nix 53 | strategy: 54 | matrix: 55 | os: [ubuntu-22.04, macos-12] 56 | runs-on: ubuntu-22.04 57 | steps: 58 | - name: git checkout 59 | uses: actions/checkout@v3 60 | - name: Set up Rust cache 61 | uses: actions/cache@v3 62 | with: 63 | path: | 64 | ~/.cargo/bin/ 65 | ~/.cargo/registry/index/ 66 | ~/.cargo/registry/cache/ 67 | ~/.cargo/git/db/ 68 | target/ 69 | key: todos-app-${{ hashFiles('**/Cargo.lock') }} 70 | - name: Set up Rust toolchain 71 | uses: actions-rs/toolchain@v1 72 | with: 73 | # Required because this Action recognizes rust-toolchain 74 | # but not rust-toolchain.toml 75 | toolchain: "1.63.0" 76 | profile: minimal 77 | components: clippy, rustfmt 78 | - name: Test TODOs API 79 | uses: actions-rs/cargo@v1 80 | with: 81 | command: test 82 | args: --no-fail-fast 83 | - name: Build TODOs API 84 | uses: actions-rs/cargo@v1 85 | with: 86 | command: build 87 | args: --release --all-features 88 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | 3 | result 4 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "ansi_term" 7 | version = "0.12.1" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" 10 | dependencies = [ 11 | "winapi", 12 | ] 13 | 14 | [[package]] 15 | name = "async-trait" 16 | version = "0.1.57" 17 | source = "registry+https://github.com/rust-lang/crates.io-index" 18 | checksum = "76464446b8bc32758d7e88ee1a804d9914cd9b1cb264c029899680b0be29826f" 19 | dependencies = [ 20 | "proc-macro2", 21 | "quote", 22 | "syn", 23 | ] 24 | 25 | [[package]] 26 | name = "autocfg" 27 | version = "1.1.0" 28 | source = "registry+https://github.com/rust-lang/crates.io-index" 29 | checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" 30 | 31 | [[package]] 32 | name = "axum" 33 | version = "0.5.16" 34 | source = "registry+https://github.com/rust-lang/crates.io-index" 35 | checksum = "c9e3356844c4d6a6d6467b8da2cffb4a2820be256f50a3a386c9d152bab31043" 36 | dependencies = [ 37 | "async-trait", 38 | "axum-core", 39 | "bitflags", 40 | "bytes", 41 | "futures-util", 42 | "http", 43 | "http-body", 44 | "hyper", 45 | "itoa", 46 | "matchit", 47 | "memchr", 48 | "mime", 49 | "percent-encoding", 50 | "pin-project-lite", 51 | "serde", 52 | "serde_json", 53 | "serde_urlencoded", 54 | "sync_wrapper", 55 | "tokio", 56 | "tower", 57 | "tower-http", 58 | "tower-layer", 59 | "tower-service", 60 | ] 61 | 62 | [[package]] 63 | name = "axum-core" 64 | version = "0.2.8" 65 | source = "registry+https://github.com/rust-lang/crates.io-index" 66 | checksum = "d9f0c0a60006f2a293d82d571f635042a72edf927539b7685bd62d361963839b" 67 | dependencies = [ 68 | "async-trait", 69 | "bytes", 70 | "futures-util", 71 | "http", 72 | "http-body", 73 | "mime", 74 | "tower-layer", 75 | "tower-service", 76 | ] 77 | 78 | [[package]] 79 | name = "bitflags" 80 | version = "1.3.2" 81 | source = "registry+https://github.com/rust-lang/crates.io-index" 82 | checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" 83 | 84 | [[package]] 85 | name = "bytes" 86 | version = "1.2.1" 87 | source = "registry+https://github.com/rust-lang/crates.io-index" 88 | checksum = "ec8a7b6a70fde80372154c65702f00a0f56f3e1c36abbc6c440484be248856db" 89 | 90 | [[package]] 91 | name = "cfg-if" 92 | version = "1.0.0" 93 | source = "registry+https://github.com/rust-lang/crates.io-index" 94 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 95 | 96 | [[package]] 97 | name = "fnv" 98 | version = "1.0.7" 99 | source = "registry+https://github.com/rust-lang/crates.io-index" 100 | checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" 101 | 102 | [[package]] 103 | name = "form_urlencoded" 104 | version = "1.1.0" 105 | source = "registry+https://github.com/rust-lang/crates.io-index" 106 | checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" 107 | dependencies = [ 108 | "percent-encoding", 109 | ] 110 | 111 | [[package]] 112 | name = "futures-channel" 113 | version = "0.3.24" 114 | source = "registry+https://github.com/rust-lang/crates.io-index" 115 | checksum = "30bdd20c28fadd505d0fd6712cdfcb0d4b5648baf45faef7f852afb2399bb050" 116 | dependencies = [ 117 | "futures-core", 118 | ] 119 | 120 | [[package]] 121 | name = "futures-core" 122 | version = "0.3.24" 123 | source = "registry+https://github.com/rust-lang/crates.io-index" 124 | checksum = "4e5aa3de05362c3fb88de6531e6296e85cde7739cccad4b9dfeeb7f6ebce56bf" 125 | 126 | [[package]] 127 | name = "futures-task" 128 | version = "0.3.24" 129 | source = "registry+https://github.com/rust-lang/crates.io-index" 130 | checksum = "a6508c467c73851293f390476d4491cf4d227dbabcd4170f3bb6044959b294f1" 131 | 132 | [[package]] 133 | name = "futures-util" 134 | version = "0.3.24" 135 | source = "registry+https://github.com/rust-lang/crates.io-index" 136 | checksum = "44fb6cb1be61cc1d2e43b262516aafcf63b241cffdb1d3fa115f91d9c7b09c90" 137 | dependencies = [ 138 | "futures-core", 139 | "futures-task", 140 | "pin-project-lite", 141 | "pin-utils", 142 | ] 143 | 144 | [[package]] 145 | name = "hermit-abi" 146 | version = "0.1.19" 147 | source = "registry+https://github.com/rust-lang/crates.io-index" 148 | checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" 149 | dependencies = [ 150 | "libc", 151 | ] 152 | 153 | [[package]] 154 | name = "http" 155 | version = "0.2.8" 156 | source = "registry+https://github.com/rust-lang/crates.io-index" 157 | checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" 158 | dependencies = [ 159 | "bytes", 160 | "fnv", 161 | "itoa", 162 | ] 163 | 164 | [[package]] 165 | name = "http-body" 166 | version = "0.4.5" 167 | source = "registry+https://github.com/rust-lang/crates.io-index" 168 | checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" 169 | dependencies = [ 170 | "bytes", 171 | "http", 172 | "pin-project-lite", 173 | ] 174 | 175 | [[package]] 176 | name = "http-range-header" 177 | version = "0.3.0" 178 | source = "registry+https://github.com/rust-lang/crates.io-index" 179 | checksum = "0bfe8eed0a9285ef776bb792479ea3834e8b94e13d615c2f66d03dd50a435a29" 180 | 181 | [[package]] 182 | name = "httparse" 183 | version = "1.8.0" 184 | source = "registry+https://github.com/rust-lang/crates.io-index" 185 | checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" 186 | 187 | [[package]] 188 | name = "httpdate" 189 | version = "1.0.2" 190 | source = "registry+https://github.com/rust-lang/crates.io-index" 191 | checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" 192 | 193 | [[package]] 194 | name = "hyper" 195 | version = "0.14.20" 196 | source = "registry+https://github.com/rust-lang/crates.io-index" 197 | checksum = "02c929dc5c39e335a03c405292728118860721b10190d98c2a0f0efd5baafbac" 198 | dependencies = [ 199 | "bytes", 200 | "futures-channel", 201 | "futures-core", 202 | "futures-util", 203 | "http", 204 | "http-body", 205 | "httparse", 206 | "httpdate", 207 | "itoa", 208 | "pin-project-lite", 209 | "socket2", 210 | "tokio", 211 | "tower-service", 212 | "tracing", 213 | "want", 214 | ] 215 | 216 | [[package]] 217 | name = "itoa" 218 | version = "1.0.3" 219 | source = "registry+https://github.com/rust-lang/crates.io-index" 220 | checksum = "6c8af84674fe1f223a982c933a0ee1086ac4d4052aa0fb8060c12c6ad838e754" 221 | 222 | [[package]] 223 | name = "lazy_static" 224 | version = "1.4.0" 225 | source = "registry+https://github.com/rust-lang/crates.io-index" 226 | checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" 227 | 228 | [[package]] 229 | name = "libc" 230 | version = "0.2.134" 231 | source = "registry+https://github.com/rust-lang/crates.io-index" 232 | checksum = "329c933548736bc49fd575ee68c89e8be4d260064184389a5b77517cddd99ffb" 233 | 234 | [[package]] 235 | name = "log" 236 | version = "0.4.17" 237 | source = "registry+https://github.com/rust-lang/crates.io-index" 238 | checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" 239 | dependencies = [ 240 | "cfg-if", 241 | ] 242 | 243 | [[package]] 244 | name = "matchit" 245 | version = "0.5.0" 246 | source = "registry+https://github.com/rust-lang/crates.io-index" 247 | checksum = "73cbba799671b762df5a175adf59ce145165747bb891505c43d09aefbbf38beb" 248 | 249 | [[package]] 250 | name = "memchr" 251 | version = "2.5.0" 252 | source = "registry+https://github.com/rust-lang/crates.io-index" 253 | checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" 254 | 255 | [[package]] 256 | name = "mime" 257 | version = "0.3.16" 258 | source = "registry+https://github.com/rust-lang/crates.io-index" 259 | checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" 260 | 261 | [[package]] 262 | name = "mio" 263 | version = "0.8.4" 264 | source = "registry+https://github.com/rust-lang/crates.io-index" 265 | checksum = "57ee1c23c7c63b0c9250c339ffdc69255f110b298b901b9f6c82547b7b87caaf" 266 | dependencies = [ 267 | "libc", 268 | "log", 269 | "wasi", 270 | "windows-sys", 271 | ] 272 | 273 | [[package]] 274 | name = "num_cpus" 275 | version = "1.13.1" 276 | source = "registry+https://github.com/rust-lang/crates.io-index" 277 | checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" 278 | dependencies = [ 279 | "hermit-abi", 280 | "libc", 281 | ] 282 | 283 | [[package]] 284 | name = "once_cell" 285 | version = "1.15.0" 286 | source = "registry+https://github.com/rust-lang/crates.io-index" 287 | checksum = "e82dad04139b71a90c080c8463fe0dc7902db5192d939bd0950f074d014339e1" 288 | 289 | [[package]] 290 | name = "percent-encoding" 291 | version = "2.2.0" 292 | source = "registry+https://github.com/rust-lang/crates.io-index" 293 | checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" 294 | 295 | [[package]] 296 | name = "pin-project" 297 | version = "1.0.12" 298 | source = "registry+https://github.com/rust-lang/crates.io-index" 299 | checksum = "ad29a609b6bcd67fee905812e544992d216af9d755757c05ed2d0e15a74c6ecc" 300 | dependencies = [ 301 | "pin-project-internal", 302 | ] 303 | 304 | [[package]] 305 | name = "pin-project-internal" 306 | version = "1.0.12" 307 | source = "registry+https://github.com/rust-lang/crates.io-index" 308 | checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55" 309 | dependencies = [ 310 | "proc-macro2", 311 | "quote", 312 | "syn", 313 | ] 314 | 315 | [[package]] 316 | name = "pin-project-lite" 317 | version = "0.2.9" 318 | source = "registry+https://github.com/rust-lang/crates.io-index" 319 | checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" 320 | 321 | [[package]] 322 | name = "pin-utils" 323 | version = "0.1.0" 324 | source = "registry+https://github.com/rust-lang/crates.io-index" 325 | checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" 326 | 327 | [[package]] 328 | name = "proc-macro2" 329 | version = "1.0.46" 330 | source = "registry+https://github.com/rust-lang/crates.io-index" 331 | checksum = "94e2ef8dbfc347b10c094890f778ee2e36ca9bb4262e86dc99cd217e35f3470b" 332 | dependencies = [ 333 | "unicode-ident", 334 | ] 335 | 336 | [[package]] 337 | name = "quote" 338 | version = "1.0.21" 339 | source = "registry+https://github.com/rust-lang/crates.io-index" 340 | checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" 341 | dependencies = [ 342 | "proc-macro2", 343 | ] 344 | 345 | [[package]] 346 | name = "ryu" 347 | version = "1.0.11" 348 | source = "registry+https://github.com/rust-lang/crates.io-index" 349 | checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" 350 | 351 | [[package]] 352 | name = "serde" 353 | version = "1.0.145" 354 | source = "registry+https://github.com/rust-lang/crates.io-index" 355 | checksum = "728eb6351430bccb993660dfffc5a72f91ccc1295abaa8ce19b27ebe4f75568b" 356 | dependencies = [ 357 | "serde_derive", 358 | ] 359 | 360 | [[package]] 361 | name = "serde_derive" 362 | version = "1.0.145" 363 | source = "registry+https://github.com/rust-lang/crates.io-index" 364 | checksum = "81fa1584d3d1bcacd84c277a0dfe21f5b0f6accf4a23d04d4c6d61f1af522b4c" 365 | dependencies = [ 366 | "proc-macro2", 367 | "quote", 368 | "syn", 369 | ] 370 | 371 | [[package]] 372 | name = "serde_json" 373 | version = "1.0.85" 374 | source = "registry+https://github.com/rust-lang/crates.io-index" 375 | checksum = "e55a28e3aaef9d5ce0506d0a14dbba8054ddc7e499ef522dd8b26859ec9d4a44" 376 | dependencies = [ 377 | "itoa", 378 | "ryu", 379 | "serde", 380 | ] 381 | 382 | [[package]] 383 | name = "serde_urlencoded" 384 | version = "0.7.1" 385 | source = "registry+https://github.com/rust-lang/crates.io-index" 386 | checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" 387 | dependencies = [ 388 | "form_urlencoded", 389 | "itoa", 390 | "ryu", 391 | "serde", 392 | ] 393 | 394 | [[package]] 395 | name = "sharded-slab" 396 | version = "0.1.4" 397 | source = "registry+https://github.com/rust-lang/crates.io-index" 398 | checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31" 399 | dependencies = [ 400 | "lazy_static", 401 | ] 402 | 403 | [[package]] 404 | name = "smallvec" 405 | version = "1.9.0" 406 | source = "registry+https://github.com/rust-lang/crates.io-index" 407 | checksum = "2fd0db749597d91ff862fd1d55ea87f7855a744a8425a64695b6fca237d1dad1" 408 | 409 | [[package]] 410 | name = "socket2" 411 | version = "0.4.7" 412 | source = "registry+https://github.com/rust-lang/crates.io-index" 413 | checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd" 414 | dependencies = [ 415 | "libc", 416 | "winapi", 417 | ] 418 | 419 | [[package]] 420 | name = "syn" 421 | version = "1.0.101" 422 | source = "registry+https://github.com/rust-lang/crates.io-index" 423 | checksum = "e90cde112c4b9690b8cbe810cba9ddd8bc1d7472e2cae317b69e9438c1cba7d2" 424 | dependencies = [ 425 | "proc-macro2", 426 | "quote", 427 | "unicode-ident", 428 | ] 429 | 430 | [[package]] 431 | name = "sync_wrapper" 432 | version = "0.1.1" 433 | source = "registry+https://github.com/rust-lang/crates.io-index" 434 | checksum = "20518fe4a4c9acf048008599e464deb21beeae3d3578418951a189c235a7a9a8" 435 | 436 | [[package]] 437 | name = "thread_local" 438 | version = "1.1.4" 439 | source = "registry+https://github.com/rust-lang/crates.io-index" 440 | checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180" 441 | dependencies = [ 442 | "once_cell", 443 | ] 444 | 445 | [[package]] 446 | name = "todos" 447 | version = "0.1.0" 448 | dependencies = [ 449 | "axum", 450 | "hyper", 451 | "serde", 452 | "tokio", 453 | "tracing-subscriber", 454 | ] 455 | 456 | [[package]] 457 | name = "tokio" 458 | version = "1.21.2" 459 | source = "registry+https://github.com/rust-lang/crates.io-index" 460 | checksum = "a9e03c497dc955702ba729190dc4aac6f2a0ce97f913e5b1b5912fc5039d9099" 461 | dependencies = [ 462 | "autocfg", 463 | "libc", 464 | "mio", 465 | "num_cpus", 466 | "pin-project-lite", 467 | "socket2", 468 | "tokio-macros", 469 | "winapi", 470 | ] 471 | 472 | [[package]] 473 | name = "tokio-macros" 474 | version = "1.8.0" 475 | source = "registry+https://github.com/rust-lang/crates.io-index" 476 | checksum = "9724f9a975fb987ef7a3cd9be0350edcbe130698af5b8f7a631e23d42d052484" 477 | dependencies = [ 478 | "proc-macro2", 479 | "quote", 480 | "syn", 481 | ] 482 | 483 | [[package]] 484 | name = "tower" 485 | version = "0.4.13" 486 | source = "registry+https://github.com/rust-lang/crates.io-index" 487 | checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" 488 | dependencies = [ 489 | "futures-core", 490 | "futures-util", 491 | "pin-project", 492 | "pin-project-lite", 493 | "tokio", 494 | "tower-layer", 495 | "tower-service", 496 | "tracing", 497 | ] 498 | 499 | [[package]] 500 | name = "tower-http" 501 | version = "0.3.4" 502 | source = "registry+https://github.com/rust-lang/crates.io-index" 503 | checksum = "3c530c8675c1dbf98facee631536fa116b5fb6382d7dd6dc1b118d970eafe3ba" 504 | dependencies = [ 505 | "bitflags", 506 | "bytes", 507 | "futures-core", 508 | "futures-util", 509 | "http", 510 | "http-body", 511 | "http-range-header", 512 | "pin-project-lite", 513 | "tower", 514 | "tower-layer", 515 | "tower-service", 516 | ] 517 | 518 | [[package]] 519 | name = "tower-layer" 520 | version = "0.3.1" 521 | source = "registry+https://github.com/rust-lang/crates.io-index" 522 | checksum = "343bc9466d3fe6b0f960ef45960509f84480bf4fd96f92901afe7ff3df9d3a62" 523 | 524 | [[package]] 525 | name = "tower-service" 526 | version = "0.3.2" 527 | source = "registry+https://github.com/rust-lang/crates.io-index" 528 | checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" 529 | 530 | [[package]] 531 | name = "tracing" 532 | version = "0.1.36" 533 | source = "registry+https://github.com/rust-lang/crates.io-index" 534 | checksum = "2fce9567bd60a67d08a16488756721ba392f24f29006402881e43b19aac64307" 535 | dependencies = [ 536 | "cfg-if", 537 | "log", 538 | "pin-project-lite", 539 | "tracing-core", 540 | ] 541 | 542 | [[package]] 543 | name = "tracing-core" 544 | version = "0.1.29" 545 | source = "registry+https://github.com/rust-lang/crates.io-index" 546 | checksum = "5aeea4303076558a00714b823f9ad67d58a3bbda1df83d8827d21193156e22f7" 547 | dependencies = [ 548 | "once_cell", 549 | "valuable", 550 | ] 551 | 552 | [[package]] 553 | name = "tracing-log" 554 | version = "0.1.3" 555 | source = "registry+https://github.com/rust-lang/crates.io-index" 556 | checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" 557 | dependencies = [ 558 | "lazy_static", 559 | "log", 560 | "tracing-core", 561 | ] 562 | 563 | [[package]] 564 | name = "tracing-subscriber" 565 | version = "0.3.15" 566 | source = "registry+https://github.com/rust-lang/crates.io-index" 567 | checksum = "60db860322da191b40952ad9affe65ea23e7dd6a5c442c2c42865810c6ab8e6b" 568 | dependencies = [ 569 | "ansi_term", 570 | "sharded-slab", 571 | "smallvec", 572 | "thread_local", 573 | "tracing-core", 574 | "tracing-log", 575 | ] 576 | 577 | [[package]] 578 | name = "try-lock" 579 | version = "0.2.3" 580 | source = "registry+https://github.com/rust-lang/crates.io-index" 581 | checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" 582 | 583 | [[package]] 584 | name = "unicode-ident" 585 | version = "1.0.4" 586 | source = "registry+https://github.com/rust-lang/crates.io-index" 587 | checksum = "dcc811dc4066ac62f84f11307873c4850cb653bfa9b1719cee2bd2204a4bc5dd" 588 | 589 | [[package]] 590 | name = "valuable" 591 | version = "0.1.0" 592 | source = "registry+https://github.com/rust-lang/crates.io-index" 593 | checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" 594 | 595 | [[package]] 596 | name = "want" 597 | version = "0.3.0" 598 | source = "registry+https://github.com/rust-lang/crates.io-index" 599 | checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" 600 | dependencies = [ 601 | "log", 602 | "try-lock", 603 | ] 604 | 605 | [[package]] 606 | name = "wasi" 607 | version = "0.11.0+wasi-snapshot-preview1" 608 | source = "registry+https://github.com/rust-lang/crates.io-index" 609 | checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" 610 | 611 | [[package]] 612 | name = "winapi" 613 | version = "0.3.9" 614 | source = "registry+https://github.com/rust-lang/crates.io-index" 615 | checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" 616 | dependencies = [ 617 | "winapi-i686-pc-windows-gnu", 618 | "winapi-x86_64-pc-windows-gnu", 619 | ] 620 | 621 | [[package]] 622 | name = "winapi-i686-pc-windows-gnu" 623 | version = "0.4.0" 624 | source = "registry+https://github.com/rust-lang/crates.io-index" 625 | checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 626 | 627 | [[package]] 628 | name = "winapi-x86_64-pc-windows-gnu" 629 | version = "0.4.0" 630 | source = "registry+https://github.com/rust-lang/crates.io-index" 631 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 632 | 633 | [[package]] 634 | name = "windows-sys" 635 | version = "0.36.1" 636 | source = "registry+https://github.com/rust-lang/crates.io-index" 637 | checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" 638 | dependencies = [ 639 | "windows_aarch64_msvc", 640 | "windows_i686_gnu", 641 | "windows_i686_msvc", 642 | "windows_x86_64_gnu", 643 | "windows_x86_64_msvc", 644 | ] 645 | 646 | [[package]] 647 | name = "windows_aarch64_msvc" 648 | version = "0.36.1" 649 | source = "registry+https://github.com/rust-lang/crates.io-index" 650 | checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" 651 | 652 | [[package]] 653 | name = "windows_i686_gnu" 654 | version = "0.36.1" 655 | source = "registry+https://github.com/rust-lang/crates.io-index" 656 | checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" 657 | 658 | [[package]] 659 | name = "windows_i686_msvc" 660 | version = "0.36.1" 661 | source = "registry+https://github.com/rust-lang/crates.io-index" 662 | checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" 663 | 664 | [[package]] 665 | name = "windows_x86_64_gnu" 666 | version = "0.36.1" 667 | source = "registry+https://github.com/rust-lang/crates.io-index" 668 | checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" 669 | 670 | [[package]] 671 | name = "windows_x86_64_msvc" 672 | version = "0.36.1" 673 | source = "registry+https://github.com/rust-lang/crates.io-index" 674 | checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" 675 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "todos" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | axum = "0.5.16" 8 | hyper = { version = "0.14.20", features = ["client"] } 9 | serde = { version = "1.0.145", features = ["derive"] } 10 | tokio = { version = "1.21.2", features = ["macros", "rt-multi-thread"] } 11 | tracing-subscriber = "0.3.15" 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Mozilla Public License Version 2.0 2 | ================================== 3 | 4 | 1. Definitions 5 | -------------- 6 | 7 | 1.1. "Contributor" 8 | means each individual or legal entity that creates, contributes to 9 | the creation of, or owns Covered Software. 10 | 11 | 1.2. "Contributor Version" 12 | means the combination of the Contributions of others (if any) used 13 | by a Contributor and that particular Contributor's Contribution. 14 | 15 | 1.3. "Contribution" 16 | means Covered Software of a particular Contributor. 17 | 18 | 1.4. "Covered Software" 19 | means Source Code Form to which the initial Contributor has attached 20 | the notice in Exhibit A, the Executable Form of such Source Code 21 | Form, and Modifications of such Source Code Form, in each case 22 | including portions thereof. 23 | 24 | 1.5. "Incompatible With Secondary Licenses" 25 | means 26 | 27 | (a) that the initial Contributor has attached the notice described 28 | in Exhibit B to the Covered Software; or 29 | 30 | (b) that the Covered Software was made available under the terms of 31 | version 1.1 or earlier of the License, but not also under the 32 | terms of a Secondary License. 33 | 34 | 1.6. "Executable Form" 35 | means any form of the work other than Source Code Form. 36 | 37 | 1.7. "Larger Work" 38 | means a work that combines Covered Software with other material, in 39 | a separate file or files, that is not Covered Software. 40 | 41 | 1.8. "License" 42 | means this document. 43 | 44 | 1.9. "Licensable" 45 | means having the right to grant, to the maximum extent possible, 46 | whether at the time of the initial grant or subsequently, any and 47 | all of the rights conveyed by this License. 48 | 49 | 1.10. "Modifications" 50 | means any of the following: 51 | 52 | (a) any file in Source Code Form that results from an addition to, 53 | deletion from, or modification of the contents of Covered 54 | Software; or 55 | 56 | (b) any new file in Source Code Form that contains any Covered 57 | Software. 58 | 59 | 1.11. "Patent Claims" of a Contributor 60 | means any patent claim(s), including without limitation, method, 61 | process, and apparatus claims, in any patent Licensable by such 62 | Contributor that would be infringed, but for the grant of the 63 | License, by the making, using, selling, offering for sale, having 64 | made, import, or transfer of either its Contributions or its 65 | Contributor Version. 66 | 67 | 1.12. "Secondary License" 68 | means either the GNU General Public License, Version 2.0, the GNU 69 | Lesser General Public License, Version 2.1, the GNU Affero General 70 | Public License, Version 3.0, or any later versions of those 71 | licenses. 72 | 73 | 1.13. "Source Code Form" 74 | means the form of the work preferred for making modifications. 75 | 76 | 1.14. "You" (or "Your") 77 | means an individual or a legal entity exercising rights under this 78 | License. For legal entities, "You" includes any entity that 79 | controls, is controlled by, or is under common control with You. For 80 | purposes of this definition, "control" means (a) the power, direct 81 | or indirect, to cause the direction or management of such entity, 82 | whether by contract or otherwise, or (b) ownership of more than 83 | fifty percent (50%) of the outstanding shares or beneficial 84 | ownership of such entity. 85 | 86 | 2. License Grants and Conditions 87 | -------------------------------- 88 | 89 | 2.1. Grants 90 | 91 | Each Contributor hereby grants You a world-wide, royalty-free, 92 | non-exclusive license: 93 | 94 | (a) under intellectual property rights (other than patent or trademark) 95 | Licensable by such Contributor to use, reproduce, make available, 96 | modify, display, perform, distribute, and otherwise exploit its 97 | Contributions, either on an unmodified basis, with Modifications, or 98 | as part of a Larger Work; and 99 | 100 | (b) under Patent Claims of such Contributor to make, use, sell, offer 101 | for sale, have made, import, and otherwise transfer either its 102 | Contributions or its Contributor Version. 103 | 104 | 2.2. Effective Date 105 | 106 | The licenses granted in Section 2.1 with respect to any Contribution 107 | become effective for each Contribution on the date the Contributor first 108 | distributes such Contribution. 109 | 110 | 2.3. Limitations on Grant Scope 111 | 112 | The licenses granted in this Section 2 are the only rights granted under 113 | this License. No additional rights or licenses will be implied from the 114 | distribution or licensing of Covered Software under this License. 115 | Notwithstanding Section 2.1(b) above, no patent license is granted by a 116 | Contributor: 117 | 118 | (a) for any code that a Contributor has removed from Covered Software; 119 | or 120 | 121 | (b) for infringements caused by: (i) Your and any other third party's 122 | modifications of Covered Software, or (ii) the combination of its 123 | Contributions with other software (except as part of its Contributor 124 | Version); or 125 | 126 | (c) under Patent Claims infringed by Covered Software in the absence of 127 | its Contributions. 128 | 129 | This License does not grant any rights in the trademarks, service marks, 130 | or logos of any Contributor (except as may be necessary to comply with 131 | the notice requirements in Section 3.4). 132 | 133 | 2.4. Subsequent Licenses 134 | 135 | No Contributor makes additional grants as a result of Your choice to 136 | distribute the Covered Software under a subsequent version of this 137 | License (see Section 10.2) or under the terms of a Secondary License (if 138 | permitted under the terms of Section 3.3). 139 | 140 | 2.5. Representation 141 | 142 | Each Contributor represents that the Contributor believes its 143 | Contributions are its original creation(s) or it has sufficient rights 144 | to grant the rights to its Contributions conveyed by this License. 145 | 146 | 2.6. Fair Use 147 | 148 | This License is not intended to limit any rights You have under 149 | applicable copyright doctrines of fair use, fair dealing, or other 150 | equivalents. 151 | 152 | 2.7. Conditions 153 | 154 | Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted 155 | in Section 2.1. 156 | 157 | 3. Responsibilities 158 | ------------------- 159 | 160 | 3.1. Distribution of Source Form 161 | 162 | All distribution of Covered Software in Source Code Form, including any 163 | Modifications that You create or to which You contribute, must be under 164 | the terms of this License. You must inform recipients that the Source 165 | Code Form of the Covered Software is governed by the terms of this 166 | License, and how they can obtain a copy of this License. You may not 167 | attempt to alter or restrict the recipients' rights in the Source Code 168 | Form. 169 | 170 | 3.2. Distribution of Executable Form 171 | 172 | If You distribute Covered Software in Executable Form then: 173 | 174 | (a) such Covered Software must also be made available in Source Code 175 | Form, as described in Section 3.1, and You must inform recipients of 176 | the Executable Form how they can obtain a copy of such Source Code 177 | Form by reasonable means in a timely manner, at a charge no more 178 | than the cost of distribution to the recipient; and 179 | 180 | (b) You may distribute such Executable Form under the terms of this 181 | License, or sublicense it under different terms, provided that the 182 | license for the Executable Form does not attempt to limit or alter 183 | the recipients' rights in the Source Code Form under this License. 184 | 185 | 3.3. Distribution of a Larger Work 186 | 187 | You may create and distribute a Larger Work under terms of Your choice, 188 | provided that You also comply with the requirements of this License for 189 | the Covered Software. If the Larger Work is a combination of Covered 190 | Software with a work governed by one or more Secondary Licenses, and the 191 | Covered Software is not Incompatible With Secondary Licenses, this 192 | License permits You to additionally distribute such Covered Software 193 | under the terms of such Secondary License(s), so that the recipient of 194 | the Larger Work may, at their option, further distribute the Covered 195 | Software under the terms of either this License or such Secondary 196 | License(s). 197 | 198 | 3.4. Notices 199 | 200 | You may not remove or alter the substance of any license notices 201 | (including copyright notices, patent notices, disclaimers of warranty, 202 | or limitations of liability) contained within the Source Code Form of 203 | the Covered Software, except that You may alter any license notices to 204 | the extent required to remedy known factual inaccuracies. 205 | 206 | 3.5. Application of Additional Terms 207 | 208 | You may choose to offer, and to charge a fee for, warranty, support, 209 | indemnity or liability obligations to one or more recipients of Covered 210 | Software. However, You may do so only on Your own behalf, and not on 211 | behalf of any Contributor. You must make it absolutely clear that any 212 | such warranty, support, indemnity, or liability obligation is offered by 213 | You alone, and You hereby agree to indemnify every Contributor for any 214 | liability incurred by such Contributor as a result of warranty, support, 215 | indemnity or liability terms You offer. You may include additional 216 | disclaimers of warranty and limitations of liability specific to any 217 | jurisdiction. 218 | 219 | 4. Inability to Comply Due to Statute or Regulation 220 | --------------------------------------------------- 221 | 222 | If it is impossible for You to comply with any of the terms of this 223 | License with respect to some or all of the Covered Software due to 224 | statute, judicial order, or regulation then You must: (a) comply with 225 | the terms of this License to the maximum extent possible; and (b) 226 | describe the limitations and the code they affect. Such description must 227 | be placed in a text file included with all distributions of the Covered 228 | Software under this License. Except to the extent prohibited by statute 229 | or regulation, such description must be sufficiently detailed for a 230 | recipient of ordinary skill to be able to understand it. 231 | 232 | 5. Termination 233 | -------------- 234 | 235 | 5.1. The rights granted under this License will terminate automatically 236 | if You fail to comply with any of its terms. However, if You become 237 | compliant, then the rights granted under this License from a particular 238 | Contributor are reinstated (a) provisionally, unless and until such 239 | Contributor explicitly and finally terminates Your grants, and (b) on an 240 | ongoing basis, if such Contributor fails to notify You of the 241 | non-compliance by some reasonable means prior to 60 days after You have 242 | come back into compliance. Moreover, Your grants from a particular 243 | Contributor are reinstated on an ongoing basis if such Contributor 244 | notifies You of the non-compliance by some reasonable means, this is the 245 | first time You have received notice of non-compliance with this License 246 | from such Contributor, and You become compliant prior to 30 days after 247 | Your receipt of the notice. 248 | 249 | 5.2. If You initiate litigation against any entity by asserting a patent 250 | infringement claim (excluding declaratory judgment actions, 251 | counter-claims, and cross-claims) alleging that a Contributor Version 252 | directly or indirectly infringes any patent, then the rights granted to 253 | You by any and all Contributors for the Covered Software under Section 254 | 2.1 of this License shall terminate. 255 | 256 | 5.3. In the event of termination under Sections 5.1 or 5.2 above, all 257 | end user license agreements (excluding distributors and resellers) which 258 | have been validly granted by You or Your distributors under this License 259 | prior to termination shall survive termination. 260 | 261 | ************************************************************************ 262 | * * 263 | * 6. Disclaimer of Warranty * 264 | * ------------------------- * 265 | * * 266 | * Covered Software is provided under this License on an "as is" * 267 | * basis, without warranty of any kind, either expressed, implied, or * 268 | * statutory, including, without limitation, warranties that the * 269 | * Covered Software is free of defects, merchantable, fit for a * 270 | * particular purpose or non-infringing. The entire risk as to the * 271 | * quality and performance of the Covered Software is with You. * 272 | * Should any Covered Software prove defective in any respect, You * 273 | * (not any Contributor) assume the cost of any necessary servicing, * 274 | * repair, or correction. This disclaimer of warranty constitutes an * 275 | * essential part of this License. No use of any Covered Software is * 276 | * authorized under this License except under this disclaimer. * 277 | * * 278 | ************************************************************************ 279 | 280 | ************************************************************************ 281 | * * 282 | * 7. Limitation of Liability * 283 | * -------------------------- * 284 | * * 285 | * Under no circumstances and under no legal theory, whether tort * 286 | * (including negligence), contract, or otherwise, shall any * 287 | * Contributor, or anyone who distributes Covered Software as * 288 | * permitted above, be liable to You for any direct, indirect, * 289 | * special, incidental, or consequential damages of any character * 290 | * including, without limitation, damages for lost profits, loss of * 291 | * goodwill, work stoppage, computer failure or malfunction, or any * 292 | * and all other commercial damages or losses, even if such party * 293 | * shall have been informed of the possibility of such damages. This * 294 | * limitation of liability shall not apply to liability for death or * 295 | * personal injury resulting from such party's negligence to the * 296 | * extent applicable law prohibits such limitation. Some * 297 | * jurisdictions do not allow the exclusion or limitation of * 298 | * incidental or consequential damages, so this exclusion and * 299 | * limitation may not apply to You. * 300 | * * 301 | ************************************************************************ 302 | 303 | 8. Litigation 304 | ------------- 305 | 306 | Any litigation relating to this License may be brought only in the 307 | courts of a jurisdiction where the defendant maintains its principal 308 | place of business and such litigation shall be governed by laws of that 309 | jurisdiction, without reference to its conflict-of-law provisions. 310 | Nothing in this Section shall prevent a party's ability to bring 311 | cross-claims or counter-claims. 312 | 313 | 9. Miscellaneous 314 | ---------------- 315 | 316 | This License represents the complete agreement concerning the subject 317 | matter hereof. If any provision of this License is held to be 318 | unenforceable, such provision shall be reformed only to the extent 319 | necessary to make it enforceable. Any law or regulation which provides 320 | that the language of a contract shall be construed against the drafter 321 | shall not be used to construe this License against a Contributor. 322 | 323 | 10. Versions of the License 324 | --------------------------- 325 | 326 | 10.1. New Versions 327 | 328 | Mozilla Foundation is the license steward. Except as provided in Section 329 | 10.3, no one other than the license steward has the right to modify or 330 | publish new versions of this License. Each version will be given a 331 | distinguishing version number. 332 | 333 | 10.2. Effect of New Versions 334 | 335 | You may distribute the Covered Software under the terms of the version 336 | of the License under which You originally received the Covered Software, 337 | or under the terms of any subsequent version published by the license 338 | steward. 339 | 340 | 10.3. Modified Versions 341 | 342 | If you create software not governed by this License, and you want to 343 | create a new license for such software, you may create and use a 344 | modified version of this License if you rename the license and remove 345 | any references to the name of the license steward (except to note that 346 | such modified license differs from this License). 347 | 348 | 10.4. Distributing Source Code Form that is Incompatible With Secondary 349 | Licenses 350 | 351 | If You choose to distribute Source Code Form that is Incompatible With 352 | Secondary Licenses under the terms of this version of the License, the 353 | notice described in Exhibit B of this License must be attached. 354 | 355 | Exhibit A - Source Code Form License Notice 356 | ------------------------------------------- 357 | 358 | This Source Code Form is subject to the terms of the Mozilla Public 359 | License, v. 2.0. If a copy of the MPL was not distributed with this 360 | file, You can obtain one at http://mozilla.org/MPL/2.0/. 361 | 362 | If it is not possible or desirable to put the notice in a particular 363 | file, then You may include the notice in a location (such as a LICENSE 364 | file in a relevant directory) where a recipient would be likely to look 365 | for such a notice. 366 | 367 | You may add additional accurate notices of copyright ownership. 368 | 369 | Exhibit B - "Incompatible With Secondary Licenses" Notice 370 | --------------------------------------------------------- 371 | 372 | This Source Code Form is "Incompatible With Secondary Licenses", as 373 | defined by the Mozilla Public License, v. 2.0. 374 | 375 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Nix + GitHub Actions 2 | 3 | > **Note**: this repo is discussed in [Streamline your GitHub Actions 4 | > dependencies using Nix][post] on the [Determinate Systems blog][blog]. 5 | 6 | This repo houses an example project that shows you how to use [Nix] to replace 7 | (some) third-party Actions in your [GitHub Actions][actions] CI pipelines. The 8 | build artifact in the repo is a simple "TODOs" web server written in [Rust]. The 9 | CI pipeline does several things: 10 | 11 | * Checks the Rust formatting using [rustfmt] 12 | * Audits the Rust code using [`cargo-deny`][cargo-deny] 13 | * Checks the repo's files for [EditorConfig] conformance 14 | * Spellchecks the repo's files using [codespell] 15 | * Runs the service's [tests] 16 | * Builds an executable for the service 17 | 18 | But different from most repos, there are two separate pipelines here that 19 | accomplish the same thing: 20 | 21 | * [`no-nix.yml`](./.github/workflows/no-nix.yml) configures a pipeline that uses 22 | third-party Actions for *all* CI logic. 23 | * [`nix.yml`](./.github/workflows/nix.yml) configures a pipeline that replaces 24 | most third-party Actions with straightforward shell commands. 25 | 26 | [actions]: https://github.com/features/actions/ 27 | [blog]: https://determinate.systems/posts/ 28 | [cargo-deny]: https://doc.rust-lang.org/cargo/ 29 | [checkout]: https://github.com/marketplace/actions/checkout/ 30 | [codespell]: https://github.com/codespell-project/codespell/ 31 | [editorconfig]: https://editorconfig.org/ 32 | [nix]: https://nixos.org/ 33 | [post]: https://determinate.systems/posts/nix-github-actions 34 | [rust]: https://rust-lang.org/ 35 | [rustfmt]: https://rust-lang.github.io/rustfmt/ 36 | [tests]: ./src/main.rs#L47-L86 37 | -------------------------------------------------------------------------------- /deny.toml: -------------------------------------------------------------------------------- 1 | targets = [] 2 | 3 | [advisories] 4 | db-path = "~/.cargo/advisory-db" 5 | db-urls = ["https://github.com/rustsec/advisory-db"] 6 | vulnerability = "deny" 7 | unmaintained = "warn" 8 | yanked = "warn" 9 | notice = "warn" 10 | ignore = [] 11 | 12 | [licenses] 13 | unlicensed = "deny" 14 | allow = ["MIT", "Apache-2.0", "Unicode-DFS-2016"] 15 | deny = [] 16 | copyleft = "allow" 17 | allow-osi-fsf-free = "neither" 18 | default = "deny" 19 | confidence-threshold = 0.8 20 | exceptions = [] 21 | 22 | [licenses.private] 23 | ignore = false 24 | registries = [] 25 | 26 | [bans] 27 | multiple-versions = "warn" 28 | wildcards = "allow" 29 | highlight = "all" 30 | allow = [] 31 | deny = [] 32 | skip = [] 33 | skip-tree = [] 34 | 35 | [sources] 36 | unknown-registry = "warn" 37 | unknown-git = "warn" 38 | allow-registry = ["https://github.com/rust-lang/crates.io-index"] 39 | allow-git = [] 40 | 41 | [sources.allow-org] 42 | #github = [""] 43 | #gitlab = [""] 44 | #bitbucket = [""] 45 | -------------------------------------------------------------------------------- /flake.lock: -------------------------------------------------------------------------------- 1 | { 2 | "nodes": { 3 | "flake-utils": { 4 | "inputs": { 5 | "systems": "systems" 6 | }, 7 | "locked": { 8 | "lastModified": 1685518550, 9 | "narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=", 10 | "owner": "numtide", 11 | "repo": "flake-utils", 12 | "rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef", 13 | "type": "github" 14 | }, 15 | "original": { 16 | "owner": "numtide", 17 | "repo": "flake-utils", 18 | "type": "github" 19 | } 20 | }, 21 | "flake-utils_2": { 22 | "inputs": { 23 | "systems": "systems_2" 24 | }, 25 | "locked": { 26 | "lastModified": 1681202837, 27 | "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", 28 | "owner": "numtide", 29 | "repo": "flake-utils", 30 | "rev": "cfacdce06f30d2b68473a46042957675eebb3401", 31 | "type": "github" 32 | }, 33 | "original": { 34 | "owner": "numtide", 35 | "repo": "flake-utils", 36 | "type": "github" 37 | } 38 | }, 39 | "nixpkgs": { 40 | "locked": { 41 | "lastModified": 1686937888, 42 | "narHash": "sha256-WVfp9k3eSdQ6rvs4z2n4VCc8Xs5x+hYIKGEjg0qSI6I=", 43 | "owner": "NixOS", 44 | "repo": "nixpkgs", 45 | "rev": "2f9c0ffde850e882e651f5f5d1eb0041528ea9f6", 46 | "type": "github" 47 | }, 48 | "original": { 49 | "owner": "NixOS", 50 | "repo": "nixpkgs", 51 | "type": "github" 52 | } 53 | }, 54 | "root": { 55 | "inputs": { 56 | "flake-utils": "flake-utils", 57 | "nixpkgs": "nixpkgs", 58 | "rust-overlay": "rust-overlay" 59 | } 60 | }, 61 | "rust-overlay": { 62 | "inputs": { 63 | "flake-utils": "flake-utils_2", 64 | "nixpkgs": [ 65 | "nixpkgs" 66 | ] 67 | }, 68 | "locked": { 69 | "lastModified": 1686882360, 70 | "narHash": "sha256-6iWVGIdIzmx/CgXPVLPyyxxBhPGYMl8sG09S8hpQ6pc=", 71 | "owner": "oxalica", 72 | "repo": "rust-overlay", 73 | "rev": "b519b1d7a31f1bd35423990398adecc6f7dd4dd2", 74 | "type": "github" 75 | }, 76 | "original": { 77 | "owner": "oxalica", 78 | "repo": "rust-overlay", 79 | "type": "github" 80 | } 81 | }, 82 | "systems": { 83 | "locked": { 84 | "lastModified": 1681028828, 85 | "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", 86 | "owner": "nix-systems", 87 | "repo": "default", 88 | "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", 89 | "type": "github" 90 | }, 91 | "original": { 92 | "owner": "nix-systems", 93 | "repo": "default", 94 | "type": "github" 95 | } 96 | }, 97 | "systems_2": { 98 | "locked": { 99 | "lastModified": 1681028828, 100 | "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", 101 | "owner": "nix-systems", 102 | "repo": "default", 103 | "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", 104 | "type": "github" 105 | }, 106 | "original": { 107 | "owner": "nix-systems", 108 | "repo": "default", 109 | "type": "github" 110 | } 111 | } 112 | }, 113 | "root": "root", 114 | "version": 7 115 | } 116 | -------------------------------------------------------------------------------- /flake.nix: -------------------------------------------------------------------------------- 1 | { 2 | description = "Nix + GitHub Actions"; 3 | 4 | inputs = { 5 | nixpkgs.url = "github:NixOS/nixpkgs"; 6 | flake-utils.url = "github:numtide/flake-utils"; 7 | rust-overlay = { 8 | url = "github:oxalica/rust-overlay"; 9 | inputs.nixpkgs.follows = "nixpkgs"; 10 | }; 11 | }; 12 | 13 | outputs = 14 | { self 15 | , nixpkgs 16 | , flake-utils 17 | , rust-overlay 18 | }: 19 | # Non-system-specific logic 20 | let 21 | # Borrow project metadata from the Rust config 22 | meta = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).package; 23 | inherit (meta) name version; 24 | 25 | overlays = [ 26 | # Rust helpers 27 | (import rust-overlay) 28 | # Build Rust toolchain using helpers from rust-overlay 29 | (self: super: { 30 | # This supplies cargo, rustc, rustfmt, etc. 31 | rustToolchain = super.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; 32 | }) 33 | ]; 34 | in 35 | # System-specific logic 36 | flake-utils.lib.eachDefaultSystem 37 | (system: 38 | let 39 | pkgs = import nixpkgs { inherit overlays system; }; 40 | 41 | runCiLocally = pkgs.writeScriptBin "ci-local" '' 42 | echo "Checking Rust formatting..." 43 | cargo fmt --check 44 | 45 | echo "Auditing Rust dependencies..." 46 | cargo-deny check 47 | 48 | echo "Auditing editorconfig conformance..." 49 | eclint -exclude "Cargo.lock" 50 | 51 | echo "Checking spelling..." 52 | codespell \ 53 | --skip target,.git \ 54 | --ignore-words-list crate 55 | 56 | echo "Testing Rust code..." 57 | cargo test 58 | 59 | echo "Building TODOs service..." 60 | nix build .#todos 61 | ''; 62 | in 63 | { 64 | devShells = { 65 | # Unified shell environment 66 | default = pkgs.mkShell 67 | { 68 | buildInputs = [ runCiLocally ] ++ (with pkgs; [ 69 | # Rust stuff (CI + dev) 70 | rustToolchain 71 | cargo-deny 72 | 73 | # Rust stuff (dev only) 74 | cargo-edit 75 | cargo-watch 76 | 77 | # Spelling and linting 78 | codespell 79 | eclint 80 | ]); 81 | }; 82 | }; 83 | 84 | packages = rec { 85 | default = todos; 86 | 87 | todos = pkgs.rustPlatform.buildRustPackage { 88 | pname = name; 89 | inherit version; 90 | src = ./.; 91 | cargoSha256 = "sha256-nLnEn3jcSO4ChsXuCq0AwQCrq/0KWvw/xWK1s79+zBs="; 92 | release = true; 93 | }; 94 | 95 | docker = 96 | let 97 | bin = "${self.packages.${system}.todos}/bin/${name}"; 98 | in 99 | pkgs.dockerTools.buildLayeredImage { 100 | inherit name; 101 | tag = "v${version}"; 102 | 103 | config = { 104 | Entrypoint = [ bin ]; 105 | ExposedPorts."8080/tcp" = { }; 106 | }; 107 | }; 108 | }; 109 | }); 110 | } 111 | -------------------------------------------------------------------------------- /rust-toolchain.toml: -------------------------------------------------------------------------------- 1 | [toolchain] 2 | profile = "default" 3 | channel = "1.63.0" 4 | -------------------------------------------------------------------------------- /rustfmt.toml: -------------------------------------------------------------------------------- 1 | edition = "2021" 2 | 3 | 4 | # Defaults 5 | max_width = 100 6 | hard_tabs = false 7 | tab_spaces = 4 8 | newline_style = "Unix" 9 | #indent_style = "Block" 10 | use_small_heuristics = "Default" 11 | fn_call_width = 60 12 | attr_fn_like_width = 70 13 | struct_lit_width = 18 14 | struct_variant_width = 35 15 | array_width = 60 16 | chain_width = 60 17 | single_line_if_else_max_width = 50 18 | #wrap_comments = false 19 | #format_code_in_doc_comments = false 20 | #doc_comment_code_block_width = 100 21 | #comment_width = 80 22 | #normalize_comments = false 23 | #normalize_doc_attributes = false 24 | #format_strings = false 25 | #format_macro_matchers = false 26 | #format_macro_bodies = true 27 | #hex_literal_case = "Preserve" 28 | #empty_item_single_line = true 29 | #struct_lit_single_line = true 30 | #fn_single_line = false 31 | #where_single_line = false 32 | #imports_indent = "Block" 33 | #imports_layout = "Mixed" 34 | #imports_granularity = "Preserve" 35 | #group_imports = "Preserve" 36 | reorder_imports = true 37 | reorder_modules = true 38 | #reorder_impl_items = false 39 | #type_punctuation_density = "Wide" 40 | #space_before_colon = false 41 | #space_after_colon = true 42 | #spaces_around_ranges = false 43 | #binop_separator = "Front" 44 | remove_nested_parens = true 45 | #combine_control_expr = true 46 | short_array_element_width_threshold = 10 47 | #overflow_delimited_expr = false 48 | #struct_field_align_threshold = 0 49 | #enum_discrim_align_threshold = 0 50 | #match_arm_blocks = true 51 | match_arm_leading_pipes = "Never" 52 | #force_multiline_blocks = false 53 | fn_args_layout = "Tall" 54 | #brace_style = "SameLineWhere" 55 | #control_brace_style = "AlwaysSameLine" 56 | #trailing_semicolon = true 57 | #trailing_comma = "Vertical" 58 | match_block_trailing_comma = false 59 | #blank_lines_upper_bound = 1 60 | #blank_lines_lower_bound = 0 61 | #version = "One" 62 | #inline_attribute_width = 0 63 | #format_generated_files = true 64 | merge_derives = true 65 | use_try_shorthand = false 66 | use_field_init_shorthand = false 67 | force_explicit_abi = true 68 | #condense_wildcard_suffixes = false 69 | #color = "Auto" 70 | #required_version = "1.5.1" 71 | #unstable_features = false 72 | disable_all_formatting = false 73 | #skip_children = false 74 | #hide_parse_errors = false 75 | #error_on_line_overflow = false 76 | #error_on_unformatted = false 77 | #ignore = [] 78 | #emit_mode = "Files" 79 | #make_backup = false 80 | -------------------------------------------------------------------------------- /src/main.rs: -------------------------------------------------------------------------------- 1 | use std::net::SocketAddr; 2 | 3 | use axum::{response::IntoResponse, routing::get, Json, Router}; 4 | use serde::Serialize; 5 | 6 | #[derive(Serialize)] 7 | struct Todo { 8 | id: usize, 9 | task: String, 10 | done: bool, 11 | } 12 | 13 | impl Todo { 14 | fn new(id: usize, task: &'static str) -> Self { 15 | Self { 16 | id, 17 | task: String::from(task), 18 | done: false, 19 | } 20 | } 21 | } 22 | 23 | async fn todos() -> impl IntoResponse { 24 | let todos: Vec = vec![Todo::new( 25 | 1, 26 | "convert all my GitHub Actions pipelines to Nix", 27 | )]; 28 | 29 | Json(todos) 30 | } 31 | 32 | #[tokio::main] 33 | async fn main() { 34 | tracing_subscriber::fmt::init(); 35 | 36 | let addr = SocketAddr::from(([127, 0, 0, 1], 8080)); 37 | axum::Server::bind(&addr) 38 | .serve(app().into_make_service()) 39 | .await 40 | .unwrap(); 41 | } 42 | 43 | fn app() -> Router { 44 | Router::new().route("/todos", get(todos)) 45 | } 46 | 47 | #[cfg(test)] 48 | mod tests { 49 | use std::net::TcpListener; 50 | 51 | use hyper::{Body, Request}; 52 | 53 | use super::*; 54 | 55 | // Not an awesome test but it gets the job done for demo purposes 56 | #[tokio::test] 57 | async fn todos_endpoint() { 58 | let addr = SocketAddr::from(([127, 0, 0, 1], 8080)); 59 | let listener = TcpListener::bind(addr).unwrap(); 60 | 61 | tokio::spawn(async move { 62 | axum::Server::from_tcp(listener) 63 | .unwrap() 64 | .serve(app().into_make_service()) 65 | .await 66 | .unwrap(); 67 | }); 68 | 69 | let client = hyper::Client::new(); 70 | 71 | let response = client 72 | .request( 73 | Request::builder() 74 | .method(hyper::Method::GET) 75 | .uri(format!("http://{}/todos", addr)) 76 | .body(Body::empty()) 77 | .unwrap(), 78 | ) 79 | .await 80 | .unwrap(); 81 | 82 | let code = response.status(); 83 | 84 | assert_eq!(code, hyper::StatusCode::OK); 85 | } 86 | } 87 | --------------------------------------------------------------------------------