GitHub stars GitHub build goreportcard Codecov License GitHub go.mod Go version Go Reference Contributor Covenant Liberay Pay funding

Welcome to Nixpresso!

Nixpresso is a HTTP server delegating request handling to a Nix function:

{
    query ? { user = "stv0g"; }
}: {
    body = "Hello ${query.user}";
}

Nixpresso's HTTP server is written in Go, while as much as possible of request handling is implemented in Nix. Nixpresso uses the NixCpp evaluator and store for serving evaluated Nix expressions, build outputs, build logs, derivations or runs executables in a CGI-fashion.

While probably not a good idea, Nixpresso could be used to build fully featured web-applications including supportrequest/response streaming, session stores, authentication and much more.

Playground

Have a look at the playground to see all features in action.

Available handlers

Click on a handler to see more details.

Handler Source Description
assets Serve static assets such as CSS, JavaScript, and images for the examples
build-log Gets build log of a derivation
build-non-sandboxed Serve a response with a non-sandboxed build script
build-result Serve a path from a realized Nixpkgs derivation
derivation Show the derivation path of a Nixpkgs package in JSON format (append ?recursive to include dependencies)
flake Serve a path from a flake package
home Home page
nixpkgs Evaluate Nixpkgs derivations and serve them as files.
path-local Serve a path from the local file system
playground A Nix and Nixpresso playground
request-body-json Return JSON request payload a JSON response
request-body-text Return raw request payload in body
response-body-json Serve a JSON response
response-body-text Serve a static text response
router Predicate based routing
run-cat Run a cat command to demonstrate request & response streaming
run-command Run a command from a realized Nixpkgs derivation
run-env Pass environment variables to a command
run-nixos-vm Run a NixOS test in a VM and streams logs via HTTP chunked transfer encoding
run-pty Run fastfetch in a pseudo-terminal (pty)
run-script Run a shell script with streaming output
session A simple session system
template Render an HTML template with all request data
tts Synthesize speech from text using piper-tts
video Generate and render STL files for 3D printing