Skip to content

Commit

Permalink
refactor(flake)!: setup crane (#46)
Browse files Browse the repository at this point in the history
* refactor(flake): setup crane

* refactor(flake): remove devenv

* fix(flake): fix dev shell

* refactor(flake): use crane dev shell

* fix(flake): fix build inputs

* fix(flake): add cmake

* fix(deps/openssl)!: disable vendored

* chore(flake): clean comments

* fix(flake): update sha256

* fix(flake): fix clippy args

* chore: lint code

* fix(flake): set clean source filter

* chore(flake): add fmt check

* feat(ci): use nix flake check

* fix(ci/check): fix typo
  • Loading branch information
kwaa committed Jun 15, 2024
1 parent 7d49aef commit e39ff3d
Show file tree
Hide file tree
Showing 20 changed files with 135 additions and 500 deletions.
2 changes: 1 addition & 1 deletion .envrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
use flake . --override-input devenv-root "file+file://"<(printf %s "$PWD")
use flake
19 changes: 11 additions & 8 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@ jobs:
if: "!startsWith(github.ref, 'refs/tags')"
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- uses: rui314/setup-mold@v1
- uses: taiki-e/install-action@just
- uses: mozilla-actions/sccache-action@v0.0.3
- run: just fmt --check
- run: just check
- run: just lint
- run: just test
- uses: DeterminateSystems/nix-installer-action@v4
- uses: DeterminateSystems/magic-nix-cache-action@main
- run: nix flake check
# - uses: dtolnay/rust-toolchain@nightly
# - uses: rui314/setup-mold@v1
# - uses: taiki-e/install-action@just
# - uses: mozilla-actions/sccache-action@v0.0.3
# - run: just fmt --check
# - run: just check
# - run: just lint
# - run: just test
11 changes: 0 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ uuid = { version = "1.8", features = [
] }

[dependencies]
openssl = { version = "*", features = ["vendored"] }
# openssl = { version = "*", features = ["vendored"] }
hatsu_api_apub = { workspace = true }
hatsu_apub = { workspace = true }
hatsu_backend = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/api_apub/src/posts/post.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub async fn post(

let post_url = hatsu_utils::url::generate_post_url(data.domain(), post_id)?;

match Post::find_by_id(&post_url.to_string())
match Post::find_by_id(post_url.to_string())
.one(&data.conn)
.await?
{
Expand Down
2 changes: 1 addition & 1 deletion crates/api_apub/src/users/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pub async fn user(
}),
];

match PreludeUser::find_by_id(&url.to_string())
match PreludeUser::find_by_id(url.to_string())
.one(&data.conn)
.await?
{
Expand Down
2 changes: 1 addition & 1 deletion crates/api_mastodon/src/entities/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub struct Context {

impl Context {
pub async fn find_by_id(post_id: &Url, data: &Data<AppData>) -> Result<Self, AppError> {
match Post::find_by_id(&post_id.to_string())
match Post::find_by_id(post_id.to_string())
.one(&data.conn)
.await?
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub async fn status_favourited_by(
Ok(url) if url.starts_with("https://") => {
let post_url = hatsu_utils::url::generate_post_url(data.domain(), url)?;

match Post::find_by_id(&post_url.to_string())
match Post::find_by_id(post_url.to_string())
.one(&data.conn)
.await?
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub async fn status_reblogged_by(
Ok(url) if url.starts_with("https://") => {
let post_url = hatsu_utils::url::generate_post_url(data.domain(), url)?;

match Post::find_by_id(&post_url.to_string())
match Post::find_by_id(post_url.to_string())
.one(&data.conn)
.await?
{
Expand Down
4 changes: 2 additions & 2 deletions crates/apub/src/actors/db_user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ impl Object for ApubUser {
user_id: Url,
data: &Data<Self::DataType>,
) -> Result<Option<Self>, Self::Error> {
Ok(PreludeUser::find_by_id(&user_id.to_string())
Ok(PreludeUser::find_by_id(user_id.to_string())
.one(&data.conn)
.await?
.map(Into::into))
}

async fn delete(self, data: &Data<Self::DataType>) -> Result<(), Self::Error> {
let _delete_user = PreludeUser::delete_by_id(&self.id.to_string())
let _delete_user = PreludeUser::delete_by_id(self.id.to_string())
.exec(&data.conn)
.await?;
Ok(())
Expand Down
4 changes: 2 additions & 2 deletions crates/apub/src/objects/db_post.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl Object for ApubPost {
post_id: Url,
data: &Data<Self::DataType>,
) -> Result<Option<Self>, Self::Error> {
Ok(Post::find_by_id(&post_id.to_string())
Ok(Post::find_by_id(post_id.to_string())
.one(&data.conn)
.await?
.map(Into::into))
Expand Down Expand Up @@ -118,7 +118,7 @@ impl Object for ApubPost {

// 删除帖文
async fn delete(self, data: &Data<Self::DataType>) -> Result<(), Self::Error> {
let _delete_post = Post::delete_by_id(&self.id.to_string())
let _delete_post = Post::delete_by_id(self.id.to_string())
.exec(&data.conn)
.await?;
Ok(())
Expand Down
File renamed without changes.
File renamed without changes
10 changes: 2 additions & 8 deletions crates/backend/src/favicon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ pub async fn ico() -> (HeaderMap, Vec<u8>) {
HeaderValue::from_static("image/x-icon"),
);

(
headers,
include_bytes!("../../../assets/favicon.ico").to_vec(),
)
(headers, include_bytes!("../assets/favicon.ico").to_vec())
}

#[debug_handler]
Expand All @@ -25,8 +22,5 @@ pub async fn svg() -> (HeaderMap, Vec<u8>) {
HeaderValue::from_static("image/svg+xml"),
);

(
headers,
include_bytes!("../../../assets/favicon.svg").to_vec(),
)
(headers, include_bytes!("../assets/favicon.svg").to_vec())
}
2 changes: 1 addition & 1 deletion crates/nodeinfo/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pub struct NodeInfoServices {
}

impl NodeInfoServices {
fn new() -> Self {
const fn new() -> Self {
Self {
inbound: vec![],
outbound: vec![],
Expand Down
1 change: 1 addition & 0 deletions crates/utils/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ impl AppEnv {
})
}

#[must_use]
pub fn info() -> String {
let version = env!("CARGO_PKG_VERSION");
let codename = "celluloid";
Expand Down
2 changes: 1 addition & 1 deletion crates/well_known/src/routes/webfinger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub async fn webfinger(

let url = hatsu_utils::url::generate_user_url(data.domain(), name)?;

match User::find_by_id(&url.to_string()).one(&data.conn).await? {
match User::find_by_id(url.to_string()).one(&data.conn).await? {
// TODO: (optional) http://webfinger.net/rel/avatar
Some(user) => Ok(Json(build_webfinger_response(
query.resource,
Expand Down
32 changes: 0 additions & 32 deletions devenv.nix

This file was deleted.

Loading

0 comments on commit e39ff3d

Please sign in to comment.