I published my first / library!

Niccup: Hiccup-like HTML Generation in ~120 Lines of Pure Nix.

Transforms Nix expressions into HTML.

The website has some cool examples, I'm especially proud of the quine one that was slightly tricky to get right: embedding-shapes.github.io/nic

Website: embedding-shapes.github.io/nic

And a softer introduction blog post with motivation and more background: embedding-shapes.github.io/int

Examples

let h = inputs.niccup.lib; in
h.render [
  "div#main.container"
  { lang = "en"; class = [ "app" "dark" ]; }
  [ "h1" "Hello from Nix" ]
  [ "p" "Hiccup-style HTML in Nix." ]
  (h.comment "List example")
  [ "ul" (map (x: [ "li.item" x ]) [ "one" "two" "three" ]) ]
]

Write to file (use nixpkgs writeText):

{ pkgs, inputs, ... }:
pkgs.writeText "index.html" (inputs.niccup.lib.render [ "p" "Hello" ])

Some more involved examples:

    art - Generative SVG (Sierpinski triangle)
    blog - Multi-page blog with navigation
    docs - NixOS module documentation generator
    quine - Self-rendering page

The website for niccup is generated dynamically with niccup too, the whole source is ~120 lines of Nix as well
0

If you have a fediverse account, you can quote this note from your own instance. Search https://mastodon.social/ap/users/115657601283172597/statuses/115657625361690948 on your instance and quote it. (Note that quoting is not supported in Mastodon.)