quine

A HTML Quine Made with Nix

Last verified:

Visit quine

What is quine?

niccup is a Hiccup-style HTML generation library for Nix that lets you describe HTML as Nix lists and attrsets, then render it to strings. The quine example is a self-rendering page built with niccup that displays the exact flake.nix and build.nix used to generate the page itself. It is designed to show off niccup’s ability to generate real HTML, include styling, and embed source code as content without breaking the rendering model.

The example demonstrates a fully self-contained Nix build that produces a static HTML file. It uses niccup’s render function, CSS injection through raw HTML, and standard HTML structures like head, body, pre, and code. The result is a page that documents its own construction and proves that the generated output matches the source used to create it.

This is mainly for Nix users, functional-programming enthusiasts, and developers interested in HTML generation systems or self-referential programs. It is also useful as a showcase for people evaluating niccup for documentation sites, static pages, or programmatic UI generation. Because the example is intentionally minimal and technical, it is best suited to users who are comfortable reading Nix code and build expressions.

More broadly, the page serves as a demonstration of niccup’s rendering model, escaping behavior, and support for raw HTML when needed. It highlights how niccup can build polished pages from concise data structures while still giving the author fine-grained control over the final markup. The quine aspect makes it a memorable proof-of-concept rather than a general-purpose app.

quine pricing

Pricing model: Freemium

The niccup site does not show a paid pricing model for the quine example; it is presented as a free example of the niccup library. The main niccup project is available as a GitHub-based flake and non-flake install, and the website/docs describe the library and examples without listing subscription tiers or paid plans. The quine example itself is just source code and build output, so the included value is the example page, the Nix files, and the ability to build the same page locally.

quine pros

  • Self-rendering quine demonstration
  • Built entirely with niccup
  • Shows real Nix-based HTML generation
  • Produces a static index.html output
  • Cross-platform flake configuration
  • Uses the same tool to generate its own docs
  • Demonstrates render function usage
  • Shows raw HTML injection for CSS
  • Illustrates escaped source-code display
  • Includes responsive viewport metadata
  • Supports dark-mode styling
  • Uses standard semantic HTML tags
  • Shows code blocks with preserved formatting
  • Outputs a reproducible build artifact
  • Good proof-of-concept for static sites
  • Easy to inspect and verify
  • Minimal moving parts
  • Highlights self-contained Nix packaging

quine cons

  • Requires familiarity with Nix
  • Source-heavy example, not beginner-friendly
  • Not an interactive application
  • Depends on trusted input assumptions
  • Uses raw HTML for styling, which is risky with untrusted content
  • Primarily a demonstration, not a reusable app
  • Limited to static page generation
  • No configuration UI or runtime options
  • Output is intentionally minimal

Frequently asked questions about quine

What does the quine example actually do?

It generates a web page that prints the very Nix files used to build it, so the page documents its own source. The example renders flake.nix and build.nix into the output page and then packages that page as index.html.

How is the page built?

The build reads flake.nix and build.nix as text, inserts them into niccup-generated HTML, and uses pkgs.runCommand to copy the rendered HTML into the final output directory. The result is a static page produced by a Nix build.

What niccup features does it demonstrate?

It demonstrates render, raw HTML insertion, HTML element composition, attribute handling, and code-block rendering. It also shows that niccup can produce both structure and styling for a complete page.

Why is raw HTML used in the example?

Raw HTML is used to embed the CSS style block without escaping it as text. That allows the page to include a full stylesheet directly inside the generated HTML.

Is this example interactive?

No, it is a static self-rendering page. Its purpose is to show a reproducible HTML output and a self-referential build, not to provide interactive features.

Who is this example for?

It is aimed at Nix users, people exploring niccup, and developers interested in programmatic HTML generation or quines. It is especially relevant if you want to build static pages from Nix expressions.

What files are needed to reproduce it?

The example is built from flake.nix and build.nix. Those two files contain the build description and the page generator, and the page itself tells you to copy both files and run nix build.

Does it depend on external runtime services?

No, the example is self-contained and builds a local static page. It relies on the niccup library and Nixpkgs during the build, but not on a server-side application at runtime.

What is the output of the build?

The build produces a directory containing index.html. That HTML file is the rendered quine page.

Why is this example notable?

It is notable because the website says the quine page itself was generated with niccup, and the example cleanly demonstrates self-reference in a practical Nix workflow. It is a compact proof that niccup can generate its own site and examples.

Use cases

Browse all AI tools on NeedAnAI