diff --git a/.gitignore b/.gitignore
index 6b847442..637468b7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,4 @@
/requirements/export
/target
result
+whitepaper/main.pdf
diff --git a/flake.lock b/flake.lock
index e9f48e5c..21b3ce75 100644
--- a/flake.lock
+++ b/flake.lock
@@ -76,6 +76,22 @@
"type": "github"
}
},
+ "nixpkgs-unstable": {
+ "locked": {
+ "lastModified": 1731139594,
+ "narHash": "sha256-IigrKK3vYRpUu+HEjPL/phrfh7Ox881er1UEsZvw9Q4=",
+ "owner": "nixos",
+ "repo": "nixpkgs",
+ "rev": "76612b17c0ce71689921ca12d9ffdc9c23ce40b2",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nixos",
+ "ref": "nixos-unstable",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
"nixpkgs_2": {
"locked": {
"lastModified": 1731239293,
@@ -98,7 +114,10 @@
"fenix": "fenix",
"naersk": "naersk",
"nixpkgs": "nixpkgs_2",
+ "nixpkgs-unstable": "nixpkgs-unstable",
"treefmt-nix": "treefmt-nix",
+ "typix": "typix",
+ "typst-packages": "typst-packages",
"utils": "utils"
}
},
@@ -154,6 +173,42 @@
"type": "github"
}
},
+ "typix": {
+ "inputs": {
+ "nixpkgs": [
+ "nixpkgs-unstable"
+ ]
+ },
+ "locked": {
+ "lastModified": 1731352170,
+ "narHash": "sha256-2JOC9lrFa0NfP9kfaT3dnm8WG5yAeDPONHJeMYl+O60=",
+ "owner": "loqusion",
+ "repo": "typix",
+ "rev": "7365cb7e6665350cb7b013abba1cbb70fcf07c53",
+ "type": "github"
+ },
+ "original": {
+ "owner": "loqusion",
+ "repo": "typix",
+ "type": "github"
+ }
+ },
+ "typst-packages": {
+ "flake": false,
+ "locked": {
+ "lastModified": 1731485222,
+ "narHash": "sha256-uhXDznbGLS4s6d2S8OHUCzpgmJQ1H2HCJug7kRIY0Jw=",
+ "owner": "typst",
+ "repo": "packages",
+ "rev": "4979ee3923fb0143e5d076854cb0d94bbf367a2c",
+ "type": "github"
+ },
+ "original": {
+ "owner": "typst",
+ "repo": "packages",
+ "type": "github"
+ }
+ },
"utils": {
"inputs": {
"systems": "systems"
diff --git a/flake.nix b/flake.nix
index ea75a4cd..d95c7100 100644
--- a/flake.nix
+++ b/flake.nix
@@ -3,6 +3,15 @@
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05";
+ nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
+ typst-packages = {
+ url = "github:typst/packages";
+ flake = false;
+ };
+ typix = {
+ url = "github:loqusion/typix";
+ inputs.nixpkgs.follows = "nixpkgs-unstable";
+ };
utils.url = "git+https://github.com/numtide/flake-utils.git";
devshell.url = "github:numtide/devshell";
fenix = {
@@ -24,7 +33,14 @@
lib = nixpkgs.lib;
pkgs = import nixpkgs {
inherit system;
- overlays = [ devshell.overlays.default ];
+ overlays = [
+ devshell.overlays.default
+
+ # We unfortunately need the most up-to-date typst
+ (final: prev: {
+ typst = inputs.nixpkgs-unstable.legacyPackages.${pkgs.hostPlatform.system}.typst;
+ })
+ ];
};
# universal formatter
@@ -36,16 +52,15 @@
# Rust distribution for our hostSystem
fenix = inputs.fenix.packages.${system};
- rust-toolchain = with fenix;
- combine [
- latest.rustc
- latest.cargo
- latest.clippy
- latest.rustfmt
- targets.${rust-target}.latest.rust-std
- targets.thumbv6m-none-eabi.latest.rust-std # for no_std test
- targets.wasm32-unknown-unknown.latest.rust-std
- ];
+ rust-toolchain = with fenix; combine [
+ latest.rustc
+ latest.cargo
+ latest.clippy
+ latest.rustfmt
+ targets.${rust-target}.latest.rust-std
+ targets.thumbv6m-none-eabi.latest.rust-std # for no_std test
+ targets.wasm32-unknown-unknown.latest.rust-std
+ ];
# overrides a naersk-lib which uses the stable toolchain expressed above
naersk-lib = (naersk.lib.${system}.override {
@@ -53,14 +68,31 @@
rustc = rust-toolchain;
});
+ typstPackagesCache = pkgs.stdenv.mkDerivation {
+ name = "typst-packages-cache";
+ src = inputs.typst-packages;
+ dontBuild = true;
+ installPhase = ''
+ mkdir -p "$out/typst/packages"
+ cp --dereference --no-preserve=mode --recursive --reflink=auto \
+ --target-directory="$out/typst/packages" -- "$src"/packages/*
+ '';
+ };
in
{
# packages
packages.wasm-interpreter = pkgs.callPackage pkgs/wasm-interpreter.nix { };
+ packages.whitepaper = inputs.typix.lib.${system}.buildTypstProject {
+ name = "whitepaper.pdf";
+ src = ./whitepaper;
+ XDG_CACHE_HOME = typstPackagesCache;
+ };
+
packages.report = pkgs.callPackage pkgs/report.nix {
- inherit (self.packages.${system}) wasm-interpreter;
+ inherit (self.packages.${system}) wasm-interpreter whitepaper;
};
+
# a devshell with all the necessary bells and whistles
devShells.default = (pkgs.devshell.mkShell {
imports = [ "${devshell}/extra/git/hooks.nix" ];
@@ -84,6 +116,7 @@
nixpkgs-fmt
nodePackages.prettier
treefmtEval.config.build.wrapper
+ typst # for the whitepaper
];
env = [
{
@@ -132,6 +165,13 @@
'';
help = "start cargo watch loop for documentation";
}
+ {
+ name = "whitepaper-watch";
+ command = ''
+ typst watch --root "$PRJ_ROOT/whitepaper" "$PRJ_ROOT/whitepaper/main.typ"
+ '';
+ help = "start typst watch loop for the whitepaper";
+ }
];
});
diff --git a/pkgs/report.nix b/pkgs/report.nix
index 0bf701bf..3efff931 100644
--- a/pkgs/report.nix
+++ b/pkgs/report.nix
@@ -1,4 +1,4 @@
-{ lib, stdenvNoCC, python3Packages, strictdoc, wasm-interpreter }:
+{ lib, stdenvNoCC, python3Packages, strictdoc, wasm-interpreter, whitepaper }:
let
evidenceRoot = lib.strings.escapeShellArg wasm-interpreter;
@@ -22,6 +22,7 @@ stdenvNoCC.mkDerivation {
cp --recursive -- ${evidenceRoot}/bench-html bench
cp --recursive -- ${evidenceRoot}/lcov-html coverage
cp --recursive -- ${evidenceRoot}/share/doc/ rustdoc
+ cp --dereference -- ${whitepaper} whitepaper.pdf
mkdir test
junit2html ${evidenceRoot}/junit.xml test/index.html
diff --git a/pkgs/report_index.html b/pkgs/report_index.html
index 5dd9d289..d8be26f0 100644
--- a/pkgs/report_index.html
+++ b/pkgs/report_index.html
@@ -47,5 +47,6 @@
Tests
Coverage
Benchmark
+ Whitepaper