···11-name: "CI Nix"
22-on:
33- # Run only when pushing to master branch, and making PRs
44- push:
55- branches:
66- - master
77- pull_request:
88-jobs:
99- build:
1010- runs-on: ${{ matrix.os }}
1111- strategy:
1212- matrix:
1313- os: [ubuntu-latest, macos-14]
1414- steps:
1515- - uses: actions/checkout@v4
1616- - uses: nixbuild/nix-quick-install-action@v33
1717- - name: Install omnix
1818- run: nix --accept-flake-config profile install "github:juspay/omnix"
1919- - run: om ci
-24
.github/workflows/ci.yml
···11-on: [push]
22-33-name: CI
44-55-jobs:
66- check:
77- name: Rust project
88- runs-on: ubuntu-latest
99- steps:
1010- - uses: actions/checkout@v2
1111- - name: Install latest nightly
1212- uses: actions-rs/toolchain@v1
1313- with:
1414- toolchain: nightly
1515- override: true
1616- components: rustfmt, clippy
1717-1818- # `cargo check` command here will use installed `nightly`
1919- # as it is set as an "override" for current directory
2020-2121- - name: Run cargo check
2222- uses: actions-rs/cargo@v1
2323- with:
2424- command: check
+13-32
README.md
···11-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).
11+# Jacquard
2233-> [!NOTE]
44-> 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).
33+A suite of Rust crates for the AT Protocol.
5466-## Usage
55+## Goals
7688-You can use [omnix](https://omnix.page/om/init.html)[^omnix] to initialize this template:
99-```
1010-nix run nixpkgs#omnix -- init github:srid/jacquard -o ~/my-rust-project
1111-```
77+- Validated, spec-compliant, easy to work with, and performant baseline types (including typed at:// uris)
88+- Batteries-included, but easily replaceable batteries.
99+ - Easy to extend with custom lexicons
1010+- lexicon Value type for working with unknown atproto data (dag-cbor or json)
1111+- order of magnitude less boilerplate than some existing crates
1212+ - either the codegen produces code that's easy to work with, or there are good handwritten wrappers
1313+- didDoc type with helper methods for getting handles, multikey, and PDS endpoint
1414+- use as much or as little from the crates as you need
12151313-[^omnix]: If initializing manually, make sure to:
1414- - Change `name` in Cargo.toml.
1515- - Run `cargo generate-lockfile` in the nix shelld
1616-1717-## Adapting this template
1818-1919-- 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.
2020-2121-## Development (Flakes)
1616+## Development
22172318This repo uses [Flakes](https://nixos.asia/en/flakes) from the get-go.
2419···3328nix build
3429```
35303636-We also provide a [`justfile`](https://just.systems/) for Makefile'esque commands to be run inside of the devShell.
3737-3838-## Tips
3939-4040-- Run `nix flake update` to update all flake inputs.
4141-- Run `nix --accept-flake-config run github:juspay/omnix ci` to build _all_ outputs.
4242-- [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.).
4343-4444-## Discussion
4545-4646-- [Zulip](https://nixos.zulipchat.com/#narrow/stream/413950-nix)
4747-4848-## See Also
4949-5050-- [nixos.wiki: Packaging Rust projects with nix](https://nixos.wiki/wiki/Rust#Packaging_Rust_projects_with_nix)
3131+There's also a [`justfile`](https://just.systems/) for Makefile-esque commands to be run inside of the devShell, and you can generally `cargo ...` or `just ...` whatever just fine if you don't want to use Nix and have the prerequisites installed.
+2-6
crates/jacquard-common/src/types/tid.rs
···100100 /// timestamps from other sources.
101101 /// If you are only using a single clock source, you can just specify `0` for `clkid`.
102102 ///
103103- /// _Warning:_ It's possible that this function will return the same time more than once.
104104- /// If it's important that these values be unique, you will want to repeatedly call this
105105- /// function until a different time is returned.
103103+ /// TODO: fix to auto-increment if it would return the same value twice
106104 pub fn now(clkid: LimitedU32<1023>) -> Self {
107105 Self::from_datetime(clkid, chrono::Utc::now())
108106 }
109107110108 /// Construct a new [Tid] that represents the current time with clkid 0.
111109 ///
112112- /// _Warning:_ It's possible that this function will return the same time more than once.
113113- /// If it's important that these values be unique, you will want to repeatedly call this
114114- /// function until a different time is returned.
110110+ /// TODO: fix to auto-increment if it would return the same value twice
115111 pub fn now_0() -> Self {
116112 Self::from_datetime(LimitedU32::from_str("0").unwrap(), chrono::Utc::now())
117113 }