aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.toml1
-rw-r--r--Earthfile4
-rw-r--r--Makefile.toml2
-rw-r--r--flake.lock132
-rw-r--r--flake.nix46
-rw-r--r--rust-toolchain.toml2
-rw-r--r--src/main.rs2
-rw-r--r--src/modules/api/sydney.rs46
-rw-r--r--src/modules/blog/module.rs2
-rw-r--r--src/modules/web.rs4
10 files changed, 209 insertions, 32 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 9af643f..4631024 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -48,6 +48,7 @@ chardetng = "0.1.17" # Character Encoding Detection
amenadiel = { version = "*", path = "./amenadiel" } # Procedural Macros
tl = "0.7.8" # HTMl Parser
url = "2.3.1" # WHATWG URL Parser
+time = "0.3.36" # Pin time to ignore nightly warnings
[build-dependencies]
vergen = { version = "8.3.1", features = [
diff --git a/Earthfile b/Earthfile
index a6cd4ae..04d715f 100644
--- a/Earthfile
+++ b/Earthfile
@@ -20,7 +20,7 @@ docker:
SAVE IMAGE --push fuwn/locus:$tag
deps:
- ARG rustc="nightly-2024-02-01"
+ ARG rustc="nightly"
FROM clux/muslrust:$rustc
@@ -30,7 +30,7 @@ deps:
&& rm rustup-init
RUN ~/.cargo/bin/rustup target add x86_64-unknown-linux-musl
RUN echo "[build]\ntarget = \"x86_64-unknown-linux-musl\"" > ~/.cargo/config
- RUN rustup component add rust-src --toolchain nightly-2024-02-01-x86_64-unknown-linux-gnu
+ RUN rustup component add rust-src --toolchain nightly-x86_64-unknown-linux-gnu
build:
FROM +deps
diff --git a/Makefile.toml b/Makefile.toml
index 894043b..ee003f3 100644
--- a/Makefile.toml
+++ b/Makefile.toml
@@ -7,7 +7,7 @@ CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true
[tasks.fmt]
args = ["fmt"]
command = "cargo"
-toolchain = "nightly"
+# toolchain = "nightly"
workspace = true
[tasks.check]
diff --git a/flake.lock b/flake.lock
new file mode 100644
index 0000000..c9f59aa
--- /dev/null
+++ b/flake.lock
@@ -0,0 +1,132 @@
+{
+ "nodes": {
+ "flake-utils": {
+ "inputs": {
+ "systems": "systems"
+ },
+ "locked": {
+ "lastModified": 1710146030,
+ "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
+ "type": "github"
+ },
+ "original": {
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "type": "github"
+ }
+ },
+ "gitignore": {
+ "inputs": {
+ "nixpkgs": [
+ "nixpkgs"
+ ]
+ },
+ "locked": {
+ "lastModified": 1709087332,
+ "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=",
+ "owner": "hercules-ci",
+ "repo": "gitignore.nix",
+ "rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
+ "type": "github"
+ },
+ "original": {
+ "owner": "hercules-ci",
+ "repo": "gitignore.nix",
+ "type": "github"
+ }
+ },
+ "naersk": {
+ "inputs": {
+ "nixpkgs": "nixpkgs"
+ },
+ "locked": {
+ "lastModified": 1717067539,
+ "narHash": "sha256-oIs5EF+6VpHJRvvpVWuqCYJMMVW/6h59aYUv9lABLtY=",
+ "owner": "nix-community",
+ "repo": "naersk",
+ "rev": "fa19d8c135e776dc97f4dcca08656a0eeb28d5c0",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nix-community",
+ "repo": "naersk",
+ "type": "github"
+ }
+ },
+ "nixpkgs": {
+ "locked": {
+ "lastModified": 1718428119,
+ "narHash": "sha256-WdWDpNaq6u1IPtxtYHHWpl5BmabtpmLnMAx0RdJ/vo8=",
+ "owner": "NixOS",
+ "repo": "nixpkgs",
+ "rev": "e6cea36f83499eb4e9cd184c8a8e823296b50ad5",
+ "type": "github"
+ },
+ "original": {
+ "id": "nixpkgs",
+ "type": "indirect"
+ }
+ },
+ "nixpkgs-mozilla": {
+ "flake": false,
+ "locked": {
+ "lastModified": 1704373101,
+ "narHash": "sha256-+gi59LRWRQmwROrmE1E2b3mtocwueCQqZ60CwLG+gbg=",
+ "owner": "mozilla",
+ "repo": "nixpkgs-mozilla",
+ "rev": "9b11a87c0cc54e308fa83aac5b4ee1816d5418a2",
+ "type": "github"
+ },
+ "original": {
+ "owner": "mozilla",
+ "repo": "nixpkgs-mozilla",
+ "type": "github"
+ }
+ },
+ "nixpkgs_2": {
+ "locked": {
+ "lastModified": 1718428119,
+ "narHash": "sha256-WdWDpNaq6u1IPtxtYHHWpl5BmabtpmLnMAx0RdJ/vo8=",
+ "owner": "NixOS",
+ "repo": "nixpkgs",
+ "rev": "e6cea36f83499eb4e9cd184c8a8e823296b50ad5",
+ "type": "github"
+ },
+ "original": {
+ "owner": "NixOS",
+ "ref": "nixpkgs-unstable",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
+ "root": {
+ "inputs": {
+ "flake-utils": "flake-utils",
+ "gitignore": "gitignore",
+ "naersk": "naersk",
+ "nixpkgs": "nixpkgs_2",
+ "nixpkgs-mozilla": "nixpkgs-mozilla"
+ }
+ },
+ "systems": {
+ "locked": {
+ "lastModified": 1681028828,
+ "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
+ "owner": "nix-systems",
+ "repo": "default",
+ "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nix-systems",
+ "repo": "default",
+ "type": "github"
+ }
+ }
+ },
+ "root": "root",
+ "version": 7
+}
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 0000000..54fc53e
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,46 @@
+{
+ inputs = {
+ nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
+ nixpkgs-mozilla = {
+ url = "github:mozilla/nixpkgs-mozilla";
+ flake = false;
+ };
+ flake-utils.url = "github:numtide/flake-utils";
+ gitignore = {
+ url = "github:hercules-ci/gitignore.nix";
+ inputs.nixpkgs.follows = "nixpkgs";
+ };
+ naersk.url = "github:nix-community/naersk";
+ };
+ outputs = { self, nixpkgs, nixpkgs-mozilla, flake-utils, gitignore, naersk, ... }:
+ flake-utils.lib.eachDefaultSystem (system:
+ let
+ pkgs = (import nixpkgs) {
+ inherit system;
+ overlays = [
+ (import nixpkgs-mozilla)
+ ];
+ };
+ toolchain = (pkgs.rustChannelOf {
+ rustToolchain = ./rust-toolchain.toml;
+ sha256 = "sha256-pxvOVg97Rgb8MqUMl/c0bnMTmHGSkx/+snWXVgjzwMI=";
+ }).rust;
+ naersk' = pkgs.callPackage naersk {
+ cargo = toolchain;
+ rustc = toolchain;
+ };
+ inherit (gitignore.lib) gitignoreSource;
+ in
+ rec {
+ packages.default = naersk'.buildPackage {
+ src = gitignoreSource ./.;
+ };
+ devShell = pkgs.mkShell {
+ shellHook = ''
+ export LD_LIBRARY_PATH=${pkgs.openssl.out}/lib
+ '';
+ nativeBuildInputs = with pkgs; [ toolchain cargo-make openssl ];
+ };
+ }
+ );
+}
diff --git a/rust-toolchain.toml b/rust-toolchain.toml
index 78c155a..5d56faf 100644
--- a/rust-toolchain.toml
+++ b/rust-toolchain.toml
@@ -1,2 +1,2 @@
[toolchain]
-channel = "nightly-2024-02-01"
+channel = "nightly"
diff --git a/src/main.rs b/src/main.rs
index 91ff2c6..d5dab7a 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,4 +1,4 @@
-#![feature(const_extern_fn, async_closure, lazy_cell)]
+#![feature(const_extern_fn, async_closure)]
#![deny(
warnings,
nonstandard_style,
diff --git a/src/modules/api/sydney.rs b/src/modules/api/sydney.rs
index 037dccf..c67e54f 100644
--- a/src/modules/api/sydney.rs
+++ b/src/modules/api/sydney.rs
@@ -8,36 +8,34 @@ pub fn module(router: &mut windmark::router::Router) {
router,
"/api/sydney/version",
"Sydney's version",
- move |_context| {
- async move {
- let mut content = "0.0.0".to_string();
+ move |_context| async move {
+ let mut content = "0.0.0".to_string();
- if let Ok(response) = reqwest::Client::new()
- .get("https://api.github.com/repos/gemrest/sydney/tags")
- .header(
- "User-Agent",
- format!("{}/{}", env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION")),
- )
- .send()
- .await
- {
- if let Ok(response_content) = response.json::<Vec<Tags>>().await {
- let response_content: Vec<Tags> = response_content;
+ if let Ok(response) = reqwest::Client::new()
+ .get("https://api.github.com/repos/gemrest/sydney/tags")
+ .header(
+ "User-Agent",
+ format!("{}/{}", env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION")),
+ )
+ .send()
+ .await
+ {
+ if let Ok(response_content) = response.json::<Vec<Tags>>().await {
+ let response_content: Vec<Tags> = response_content;
- if let Some(first_tag) = response_content.first() {
- content = first_tag.name().clone();
- }
+ if let Some(first_tag) = response_content.first() {
+ content.clone_from(first_tag.name());
+ }
- if let Some(just_tag) = content.get(1..) {
- content = just_tag.to_string();
- }
+ if let Some(just_tag) = content.get(1..) {
+ content = just_tag.to_string();
}
}
-
- windmark::response::Response::success(content)
- .with_mime("text/plain")
- .clone()
}
+
+ windmark::response::Response::success(content)
+ .with_mime("text/plain")
+ .clone()
},
);
}
diff --git a/src/modules/blog/module.rs b/src/modules/blog/module.rs
index e90c380..9d00eea 100644
--- a/src/modules/blog/module.rs
+++ b/src/modules/blog/module.rs
@@ -219,7 +219,7 @@ pub fn module(router: &mut windmark::router::Router) {
for (title, contents) in entries {
let header = construct_header(&config, &title)
- .map_or_else(|()| (String::new(), String::new()), |header| header);
+ .unwrap_or_else(|()| (String::new(), String::new()));
let fixed_blog_name = fixed_blog_name_clone_2.clone();
let mut real_title = "Unknown";
diff --git a/src/modules/web.rs b/src/modules/web.rs
index 9a5369b..2bb2833 100644
--- a/src/modules/web.rs
+++ b/src/modules/web.rs
@@ -4,7 +4,7 @@ use {
route::track_mount,
url::{ROOT_GEMINI_URL, ROOT_HTTPS_URL},
},
- windmark::response::Response,
+ windmark::{context::RouteContext, response::Response},
};
fn error(message: &str, context: &windmark::context::RouteContext) -> Response {
@@ -35,7 +35,7 @@ To visit the web version of this exact page, <{ROOT_HTTPS_URL}/web>, you would v
router,
"/web/*url",
"World Wide Web to Gemini Gateway Visitor",
- async move |context| {
+ async move |context: RouteContext| {
Response::success({
let Ok(url) = url::Url::parse(&format!(
"https://{}",