Compare commits

..

3 Commits

Author SHA1 Message Date
Tom Alexander
3cdde05975 Merge branch 'nix' 2026-07-10 23:12:15 -04:00
Tom Alexander
a50240ec57 Add support for building natter via nix. 2026-07-10 23:00:28 -04:00
Tom Alexander
a410a64236 Add english language attribute to html tag. 2026-07-10 22:36:20 -04:00
46 changed files with 300 additions and 83 deletions

1
.gitignore vendored
View File

@@ -1 +1,2 @@
/target
/result

View File

@@ -48,7 +48,7 @@ default = ["tracing"]
tracing = ["dep:opentelemetry", "dep:opentelemetry-otlp", "dep:opentelemetry-semantic-conventions", "dep:tracing", "dep:tracing-opentelemetry", "dep:tracing-subscriber"]
# Optimized build for any sort of release.
[profile.release-lto]
[profile.lto]
inherits = "release"
lto = true
strip = "symbols"

View File

@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />

48
flake.lock generated Normal file
View File

@@ -0,0 +1,48 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1780749050,
"narHash": "sha256-3av0pIjlOWQ6rDbNOmpUSvbNnJkGORQKKjb4LtCZsIY=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "a799d3e3886da994fa307f817a6bc705ae538eeb",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs",
"rust-overlay": "rust-overlay"
}
},
"rust-overlay": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1781407245,
"narHash": "sha256-VzJq4MmD0uyNDAceudSe1hHqcQMe9Tau0U4S+5iRGh0=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "d5f483210eb016d66102eef22baa128b3b3233fc",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

86
flake.nix Normal file
View File

@@ -0,0 +1,86 @@
{
description = "Natter static site generator";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
nixpkgs.follows = "nixpkgs";
};
};
};
outputs =
{
self,
nixpkgs,
rust-overlay,
}:
let
forAllSystems =
func:
builtins.listToAttrs (
map (system: {
name = system;
value = func system;
}) nixpkgs.lib.systems.flakeExposed
);
in
{
devShells = forAllSystems (
system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs {
inherit system overlays;
};
rustToolchain = (pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml);
in
{
default = pkgs.mkShell {
nativeBuildInputs = [
rustToolchain
];
buildInputs = with pkgs; [
];
};
}
);
packages = forAllSystems (
system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs {
inherit system overlays;
};
appliedOverlay = self.overlays.default pkgs pkgs;
in
rec {
default = release;
inherit (appliedOverlay.natter)
release
;
docker_env = pkgs.buildEnv {
name = "natter";
paths = with pkgs; [
appliedOverlay.natter.release
bash
uutils-coreutils-noprefix
# toybox # Smaller than uutils-coreutils?
];
};
}
);
overlays.default = final: prev: {
natter = final.lib.makeScope final.newScope (natterScope: {
release = (
natterScope.callPackage ./nix/package.nix {
inherit rust-overlay;
buildType = "lto";
}
);
});
};
};
}

82
nix/package.nix Normal file
View File

@@ -0,0 +1,82 @@
{
hello,
lib,
pkgs,
rust-overlay,
targetBins ? [ ],
features ? [ ],
cargoBuildTarget ? null,
buildType ? null,
buildLib ? false,
}:
let
cargoToml = (lib.importTOML ../Cargo.toml);
rustPlatformFor =
pkgs:
let
rust-bin = rust-overlay.lib.mkRustBin { } pkgs;
rustToolchain = (rust-bin.fromRustupToolchainFile ../rust-toolchain.toml).override (
if cargoBuildTarget != null then
{
targets = [ cargoBuildTarget ];
}
else
{ }
);
baseRustPlatform = (
pkgs.makeRustPlatform {
cargo = rustToolchain;
rustc = rustToolchain;
}
);
rustPlatform =
if cargoBuildTarget != null then
baseRustPlatform.overrideScope (
final: prev: {
cargoBuildHook = prev.cargoBuildHook.overrideDerivation (_: {
rustcTargetSpec = cargoBuildTarget;
});
cargoInstallHook = hello;
}
)
else
baseRustPlatform;
in
rustPlatform;
in
(rustPlatformFor pkgs).buildRustPackage (
# rustPlatform.buildRustPackage (
{
pname = "natter";
version = cargoToml.package.version;
src = lib.cleanSource ../.;
cargoLock.lockFile = ../Cargo.lock;
cargoBuildFlags = builtins.concatLists [
(builtins.concatMap (targetBin: [
"--bin"
targetBin
]) targetBins)
(if buildLib then [ "--lib" ] else [ ])
(
if features != [ ] then
[
"--features"
(builtins.concatStringsSep " " features)
]
else
[ ]
)
];
}
// (
if buildType != null then
{
buildType = buildType;
}
else
{ }
)
)

View File

@@ -1,8 +1,8 @@
use std::ffi::OsStr;
use std::path::PathBuf;
use include_dir::Dir;
use include_dir::include_dir;
use include_dir::Dir;
use tokio::fs::DirEntry;
use tokio::task::JoinHandle;
@@ -15,15 +15,15 @@ use crate::context::RenderBlogStreamInput;
use crate::context::RenderContext;
use crate::context::RenderPage;
use crate::error::CustomError;
use crate::intermediate::get_web_path;
use crate::intermediate::BlogPost;
use crate::intermediate::IPage;
use crate::intermediate::PublishStatus;
use crate::intermediate::get_web_path;
use crate::render::DusterRenderer;
use crate::render::RendererIntegration;
use crate::walk_fs::walk_fs;
use crate::walk_fs::WalkAction;
use crate::walk_fs::WalkFsFilterResult;
use crate::walk_fs::walk_fs;
use super::stylesheet::Stylesheet;

View File

@@ -8,17 +8,17 @@ use crate::cli::parameters::BuildArgs;
use crate::command::build::render::SiteRenderer;
use crate::config::Config;
use crate::error::CustomError;
use crate::intermediate::get_org_files;
use crate::intermediate::BlogPost;
use crate::intermediate::IPage;
use crate::intermediate::IntermediateContext;
use crate::intermediate::PageInput;
use crate::intermediate::Registry;
use crate::intermediate::get_org_files;
use crate::walk_fs::walk_fs;
use crate::walk_fs::WalkAction;
use crate::walk_fs::WalkFsFilterResult;
use crate::walk_fs::walk_fs;
use include_dir::Dir;
use include_dir::include_dir;
use include_dir::Dir;
use tokio::fs::DirEntry;
static DEFAULT_STYLESHEETS: Dir =

View File

@@ -3,8 +3,6 @@ use serde::Serialize;
use crate::error::CustomError;
use crate::intermediate::IAstNode;
use super::RenderHeading;
use super::RenderSection;
use super::angle_link::RenderAngleLink;
use super::babel_call::RenderBabelCall;
use super::bold::RenderBold;
@@ -57,6 +55,8 @@ use super::timestamp::RenderTimestamp;
use super::underline::RenderUnderline;
use super::verbatim::RenderVerbatim;
use super::verse_block::RenderVerseBlock;
use super::RenderHeading;
use super::RenderSection;
#[derive(Debug, Serialize)]
#[serde(untagged)]

View File

@@ -5,15 +5,15 @@ use serde::Serialize;
use super::render_context::RenderContext;
use crate::context::macros::push_file;
use crate::error::CustomError;
use crate::intermediate::get_web_path;
use crate::intermediate::BlogPost;
use crate::intermediate::BlogPostPage;
use crate::intermediate::get_web_path;
use super::footnote_definition::RenderRealFootnoteDefinition;
use super::macros::render;
use super::GlobalSettings;
use super::PageHeader;
use super::RenderDocumentElement;
use super::footnote_definition::RenderRealFootnoteDefinition;
use super::macros::render;
#[derive(Debug)]
pub(crate) struct RenderBlogPostPageInput<'a> {

View File

@@ -4,12 +4,12 @@ use serde::Serialize;
use super::macros::render;
use super::render_context::RenderContext;
use crate::context::macros::push_file;
use crate::context::RenderDocumentElement;
use crate::context::RenderRealFootnoteDefinition;
use crate::context::macros::push_file;
use crate::error::CustomError;
use crate::intermediate::BlogPost;
use crate::intermediate::get_web_path;
use crate::intermediate::BlogPost;
use super::GlobalSettings;
use super::PageHeader;

View File

@@ -3,9 +3,9 @@ use serde::Serialize;
use crate::error::CustomError;
use crate::intermediate::IBold;
use super::RenderObject;
use super::macros::render;
use super::render_context::RenderContext;
use super::RenderObject;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]

View File

@@ -4,9 +4,9 @@ use super::render_context::RenderContext;
use crate::error::CustomError;
use crate::intermediate::IDocumentElement;
use super::macros::render;
use super::RenderHeading;
use super::RenderSection;
use super::macros::render;
#[derive(Debug, Serialize)]
#[serde(untagged)]

View File

@@ -4,9 +4,9 @@ use super::render_context::RenderContext;
use crate::error::CustomError;
use crate::intermediate::IHeading;
use super::macros::render;
use super::RenderDocumentElement;
use super::RenderObject;
use super::macros::render;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]

View File

@@ -4,8 +4,8 @@ use super::render_context::RenderContext;
use crate::error::CustomError;
use crate::intermediate::IItalic;
use super::RenderObject;
use super::macros::render;
use super::RenderObject;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]

View File

@@ -1,15 +1,15 @@
use std::collections::HashSet;
use super::GlobalSettings;
use super::PageHeader;
use super::RenderDocumentElement;
use super::footnote_definition::RenderRealFootnoteDefinition;
use super::macros::render;
use super::render_context::RenderContext;
use super::GlobalSettings;
use super::PageHeader;
use super::RenderDocumentElement;
use crate::context::macros::push_file;
use crate::error::CustomError;
use crate::intermediate::IPage;
use crate::intermediate::get_web_path;
use crate::intermediate::IPage;
use serde::Serialize;
#[derive(Debug, Serialize)]

View File

@@ -4,8 +4,8 @@ use super::render_context::RenderContext;
use crate::error::CustomError;
use crate::intermediate::IParagraph;
use super::RenderObject;
use super::macros::render;
use super::RenderObject;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]

View File

@@ -4,9 +4,9 @@ use super::render_context::RenderContext;
use crate::error::CustomError;
use crate::intermediate::IPlainListItem;
use super::macros::render;
use super::RenderElement;
use super::RenderObject;
use super::macros::render;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]

View File

@@ -4,8 +4,8 @@ use super::render_context::RenderContext;
use crate::error::CustomError;
use crate::intermediate::IPlainListSimpleItem;
use super::RenderObject;
use super::macros::render;
use super::RenderObject;
/// Special case for list items with only paragraphs and sublists as their children. In those cases, the paragraph tags are omitted. This is equivalent to a Paragraph but in a different struct to have a different type tag.
#[derive(Debug, Serialize)]

View File

@@ -4,8 +4,8 @@ use super::render_context::RenderContext;
use crate::error::CustomError;
use crate::intermediate::IQuoteBlock;
use super::RenderElement;
use super::macros::render;
use super::RenderElement;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]

View File

@@ -5,8 +5,8 @@ use crate::error::CustomError;
use crate::intermediate::IRegularLink;
use crate::intermediate::LinkTarget;
use super::RenderObject;
use super::macros::render;
use super::RenderObject;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]

View File

@@ -4,8 +4,8 @@ use super::render_context::RenderContext;
use crate::error::CustomError;
use crate::intermediate::ISection;
use super::RenderElement;
use super::macros::render;
use super::RenderElement;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]

View File

@@ -4,8 +4,8 @@ use super::render_context::RenderContext;
use crate::error::CustomError;
use crate::intermediate::IStrikeThrough;
use super::RenderObject;
use super::macros::render;
use super::RenderObject;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]

View File

@@ -4,8 +4,8 @@ use super::render_context::RenderContext;
use crate::error::CustomError;
use crate::intermediate::ITableCell;
use super::RenderObject;
use super::macros::render;
use super::RenderObject;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]

View File

@@ -4,8 +4,8 @@ use super::render_context::RenderContext;
use crate::error::CustomError;
use crate::intermediate::IUnderline;
use super::RenderObject;
use super::macros::render;
use super::RenderObject;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]

View File

@@ -1,3 +1,28 @@
use super::angle_link::IAngleLink;
use super::bold::IBold;
use super::citation::ICitation;
use super::citation_reference::ICitationReference;
use super::code::ICode;
use super::comment::IComment;
use super::entity::IEntity;
use super::export_snippet::IExportSnippet;
use super::footnote_reference::IFootnoteReference;
use super::inline_babel_call::IInlineBabelCall;
use super::inline_source_block::IInlineSourceBlock;
use super::italic::IItalic;
use super::keyword::IKeyword;
use super::latex_fragment::ILatexFragment;
use super::line_break::ILineBreak;
use super::org_macro::IOrgMacro;
use super::plain_link::IPlainLink;
use super::plain_text::IPlainText;
use super::radio_link::IRadioLink;
use super::radio_target::IRadioTarget;
use super::regular_link::IRegularLink;
use super::statistics_cookie::IStatisticsCookie;
use super::strike_through::IStrikeThrough;
use super::subscript::ISubscript;
use super::superscript::ISuperscript;
use super::IBabelCall;
use super::ICenterBlock;
use super::IClock;
@@ -27,31 +52,6 @@ use super::IUnderline;
use super::IVerbatim;
use super::IVerseBlock;
use super::IntermediateContext;
use super::angle_link::IAngleLink;
use super::bold::IBold;
use super::citation::ICitation;
use super::citation_reference::ICitationReference;
use super::code::ICode;
use super::comment::IComment;
use super::entity::IEntity;
use super::export_snippet::IExportSnippet;
use super::footnote_reference::IFootnoteReference;
use super::inline_babel_call::IInlineBabelCall;
use super::inline_source_block::IInlineSourceBlock;
use super::italic::IItalic;
use super::keyword::IKeyword;
use super::latex_fragment::ILatexFragment;
use super::line_break::ILineBreak;
use super::org_macro::IOrgMacro;
use super::plain_link::IPlainLink;
use super::plain_text::IPlainText;
use super::radio_link::IRadioLink;
use super::radio_target::IRadioTarget;
use super::regular_link::IRegularLink;
use super::statistics_cookie::IStatisticsCookie;
use super::strike_through::IStrikeThrough;
use super::subscript::ISubscript;
use super::superscript::ISuperscript;
use crate::error::CustomError;
use futures::future::{BoxFuture, FutureExt};

View File

@@ -7,12 +7,12 @@ use tokio::fs::DirEntry;
use tokio::task::JoinHandle;
use crate::error::CustomError;
use crate::intermediate::IntermediateContext;
use crate::intermediate::blog_post_page::BlogPostPageInput;
use crate::intermediate::registry::Registry;
use crate::intermediate::IntermediateContext;
use crate::walk_fs::walk_fs;
use crate::walk_fs::WalkAction;
use crate::walk_fs::WalkFsFilterResult;
use crate::walk_fs::walk_fs;
use super::BlogPostPage;

View File

@@ -4,10 +4,10 @@ use crate::error::CustomError;
use super::footnote_definition::IRealFootnoteDefinition;
use super::macros::intermediate;
use super::IDocumentElement;
use super::IHeading;
use super::ISection;
use super::macros::intermediate;
#[derive(Debug)]
pub(crate) struct BlogPostPageInput<'b, 'parse> {

View File

@@ -1,7 +1,7 @@
use organic::types::StandardProperties;
use super::IObject;
use super::macros::intermediate;
use super::IObject;
use crate::error::CustomError;

View File

@@ -1,7 +1,7 @@
use super::IPlainListSimpleItem;
use super::comment::IComment;
use super::keyword::IKeyword;
use super::macros::iselector;
use super::IPlainListSimpleItem;
use super::IBabelCall;
use super::ICenterBlock;

View File

@@ -1,7 +1,7 @@
use super::IAstNode;
use super::IntermediateContext;
use super::macros::intermediate;
use super::registry::register_footnote_definition;
use super::IAstNode;
use super::IntermediateContext;
use crate::error::CustomError;
use organic::types::StandardProperties;

View File

@@ -1,6 +1,6 @@
use super::macros::intermediate;
use super::IDocumentElement;
use super::IObject;
use super::macros::intermediate;
use crate::error::CustomError;
use organic::types::StandardProperties;

View File

@@ -1,7 +1,7 @@
use organic::types::StandardProperties;
use super::IObject;
use super::macros::intermediate;
use super::IObject;
use crate::error::CustomError;

View File

@@ -71,8 +71,8 @@ mod verse_block;
pub(crate) use angle_link::IAngleLink;
pub(crate) use ast_node::IAstNode;
pub(crate) use babel_call::IBabelCall;
pub(crate) use blog_post::BlogPost;
pub(crate) use blog_post::get_org_files;
pub(crate) use blog_post::BlogPost;
pub(crate) use blog_post_page::BlogPostPage;
pub(crate) use blog_post_page::PublishStatus;
pub(crate) use bold::IBold;

View File

@@ -21,7 +21,6 @@ use super::plain_text::IPlainText;
use super::radio_link::IRadioLink;
use super::radio_target::IRadioTarget;
use super::ITarget;
use super::regular_link::IRegularLink;
use super::statistics_cookie::IStatisticsCookie;
use super::strike_through::IStrikeThrough;
@@ -30,6 +29,7 @@ use super::superscript::ISuperscript;
use super::timestamp::ITimestamp;
use super::underline::IUnderline;
use super::verbatim::IVerbatim;
use super::ITarget;
use futures::future::{BoxFuture, FutureExt};
#[derive(Debug, Clone)]

View File

@@ -1,12 +1,12 @@
use super::IDocumentElement;
use super::IHeading;
use super::ISection;
use super::PublishStatus;
use super::blog_post_page::get_date;
use super::blog_post_page::get_publish_status;
use super::blog_post_page::get_title;
use super::footnote_definition::IRealFootnoteDefinition;
use super::macros::intermediate;
use super::IDocumentElement;
use super::IHeading;
use super::ISection;
use super::PublishStatus;
use crate::error::CustomError;
use std::path::PathBuf;

View File

@@ -1,5 +1,5 @@
use super::IObject;
use super::macros::intermediate;
use super::IObject;
use crate::error::CustomError;
use organic::types::StandardProperties;

View File

@@ -1,5 +1,5 @@
use super::IPlainListItem;
use super::macros::intermediate;
use super::IPlainListItem;
use crate::error::CustomError;
use organic::types::StandardProperties;

View File

@@ -1,5 +1,5 @@
use super::IPlainListSimpleItem;
use super::macros::intermediate;
use super::IPlainListSimpleItem;
use super::IElement;
use super::IObject;

View File

@@ -1,5 +1,5 @@
use super::IObject;
use super::macros::intermediate;
use super::IObject;
use crate::error::CustomError;
use organic::types::StandardProperties;

View File

@@ -1,5 +1,5 @@
use super::IElement;
use super::macros::intermediate;
use super::IElement;
use crate::error::CustomError;
use organic::types::StandardProperties;

View File

@@ -3,11 +3,11 @@ use organic::types::Element;
use organic::types::Object;
use std::collections::HashMap;
use super::ast_node::IAstNode;
use super::ast_node::IntoIAstNode;
use super::IObject;
use super::IParagraph;
use super::IntermediateContext;
use super::ast_node::IAstNode;
use super::ast_node::IntoIAstNode;
type IdCounter = u16;

View File

@@ -5,9 +5,9 @@ use organic::types::LinkType;
use organic::types::StandardProperties;
use url::Url;
use super::IntermediateContext;
use super::get_web_path;
use super::macros::intermediate;
use super::IntermediateContext;
use super::IObject;
use crate::context::RenderContext;

View File

@@ -1,5 +1,5 @@
use super::IElement;
use super::macros::intermediate;
use super::IElement;
use crate::error::CustomError;
use organic::types::StandardProperties;

View File

@@ -1,7 +1,7 @@
use organic::types::StandardProperties;
use super::IObject;
use super::macros::intermediate;
use super::IObject;
use crate::error::CustomError;

View File

@@ -1,7 +1,7 @@
use organic::types::StandardProperties;
use super::IObject;
use super::macros::intermediate;
use super::IObject;
use crate::error::CustomError;