No description
  • Nix 93.7%
  • Shell 6.3%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-11-21 15:46:02 +01:00
examples feat: add static files module 2026-11-21 14:50:08 +01:00
lib feat: add static files module 2026-11-21 14:50:08 +01:00
src fix: escape characters in response content 2026-11-21 15:40:59 +01:00
.gitignore feat: handler architecture 2026-11-21 00:08:40 +01:00
default.nix feat: add static files module 2026-11-21 14:50:08 +01:00
README.md docs: clarify limitations in readme 2026-11-21 15:46:02 +01:00

httpnix

Yet another HTTP Server... In Nix...

...well... almost. It is ~90% Nix and 10% Shell Script. The actual socket is implemented using netcat in a Shell Script but apart from that, everything is handled inside of Nix

How it works

The flag --allow-unsafe-native-code-during-evaluation to the nix command gives you access to builtins.exec. Given an array of command + arguments, it will parse stdout of that command into a nix expression. This essentially allows you to run commands during the evaluation phase, including netcat.

Goals

  • No nix build or nix run, everything runs during the evaluation phase
  • Parse the TCP-Messages in Nix
  • Do not use nixpkgs, just the language builtins

Limitations

  • This is extremely insecure! I can already think of at least two ways a hacker might get RCE using this software! DO NOT USE IN PRODUCTION
  • This is HTTP/1.1 only. Contributions for HTTP/2 and HTTP/3 are appreciated but HTTPS is out of scope
  • This can only proccess 1 Request at a time, which breaks html files with a lot of assets

Using it

Head over to the examples to find out, how to use this. You can run them using the following command:

nix eval --file ./default.nix --allow-unsafe-native-code-during-evaluation.

Ensure that the nc, env, sh, cat, rm and mkfifo commands are available in your PATH.

The default port is 8080.

LLM Usage

No "AI" was used while developing this. Any Contributions created with or by LLMs is prohibited

License

All code is licensed under CC0-1.0. The JSON-List of HTTP Status codes was taken from phpjsnerd's Github Gist and the JSON-List of Mimetypes from micnic's Github Repository