nanofil/web/play/default.nix
The nanofil playground: nanofil on SWI-Prolog 10.1.19 in WebAssembly, drawing what it makes of a C file with dterm (README.md). Its files go in the wiki at nanofil/play/ (packages/site), beside the dterm pages whose style.css and dterm.css it uses.
λflake?, pkgs?, filcc?, swipl?
| flake | default builtins.getFlaketoString../../.. |
| pkgs | default importflake.inputs.nixpkgs system = "x86_64-linux"; |
| filcc | default flake.packages.x86_64-linux.filcc-staging |
| swipl | default import./swipl.nix inherit pkgs; |
let
The source editor: editor/editor.js and the CodeMirror packages its package-lock.json pins, bundled and minified into one ES module.
pkgs.buildNpmPackage
Monaspace Neon for the page's monospace: the variable webfont at its normal width and upright (the weight stays variable), subset to Latin and the arrows, boxes and punctuation the page draws; 68 KB of the 511.
pkgs.runCommand"nanofil-play-neon"
unzip -q $src
fonttools varLib.instancer "Variable Web Fonts/Monaspace Neon/Monaspace Neon Var.woff2" wdth=100 slnt=0 -o neon-var.woff2
mkdir $out
pyftsubset neon-var.woff2 --layout-features='*' --flavor=woff2 --output-file=$out/neon.woff2 \
--unicodes='U+0000-00FF,U+0131,U+0152-0153,U+02C6,U+02DA,U+02DC,U+2000-206F,U+2190-21FF,U+2200-22FF,U+2500-25FF'
in
pkgs.runCommand"nanofil-play"
pkgs.lib.fileset.toSource
pkgs.lib.fileset.unions../../bin ../../src ../dterm.pl ../dterm_html.pl ../dterm.css ../dterm.js ./.
cp -r $src nanofil && chmod -R u+w nanofil
patchShebangs nanofil
LANG=C.UTF-8 FILCC=${filcc}/bin/clang SWIPL=swipl \
SWIPL_WASM=${swiplWasm}/dist/swipl nanofil/web/play/build.sh $out
# GitHub Pages sends max-age=600 with every file and cannot be told
# otherwise. Each file the page loads is named with a hash of its
# content, so a reload (which revalidates the HTML) fetches exactly
# the new build, and an unchanged file stays cached.
python3 -I ${./stamp.py} $out nanofil/web