nova-nix: Windows-native Nix implementation in Haskell and C99

[ bsd3, distribution, library, nix, program, system ] [ Propose Tags ] [ Report a vulnerability ]

A from-scratch implementation of the Nix package manager that runs natively on Windows, macOS, and Linux — no WSL or Cygwin. A Haskell evaluator handles parsing and lazy evaluation, backed by a C99 data layer that keeps evaluation data off the GHC heap. It evaluates Nix expressions (including real nixpkgs lib), computes derivations and content-addressed store paths, and includes a derivation builder and binary-cache substituter.

Built on nova-cache for NAR serialization, narinfo handling, and Ed25519-signed binary substitution.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.1.0.1, 0.1.1.0, 0.1.2.0, 0.1.3.0, 0.1.4.0, 0.1.5.0, 0.1.6.0, 0.1.7.0, 0.1.7.1, 0.1.8.0, 0.1.9.0, 0.2.0.0
Change log CHANGELOG.md
Dependencies array (>=0.5 && <0.6), base (>=4.16 && <5), bytestring (>=0.11 && <0.13), containers (>=0.6 && <0.8), crypton (>=1.0 && <1.1), directory (>=1.3 && <1.4), filepath (>=1.4 && <1.6), http-client (>=0.7 && <0.8), http-client-tls (>=0.3 && <0.4), http-types (>=0.12 && <0.13), memory (>=0.18 && <1), mtl (>=2.2 && <2.4), nova-cache (>=0.3.0 && <0.4), nova-nix, process (>=1.6 && <1.7), regex-tdfa (>=1.3 && <1.4), sqlite-simple (>=0.4 && <0.5), text (>=2.0 && <2.2), time (>=1.9 && <1.15) [details]
Tested with ghc ==9.8.4
License BSD-3-Clause
Author Devon Tomlin
Maintainer devon.tomlin@novavero.ai
Uploaded by aoinoikaz at 2026-06-05T17:46:38Z
Category Nix, Distribution, System
Home page https://github.com/Novavero-AI/nova-nix
Bug tracker https://github.com/Novavero-AI/nova-nix/issues
Source repo head: git clone https://github.com/Novavero-AI/nova-nix -b main
Distributions
Executables nova-nix
Downloads 104 total (34 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2026-06-05 [all 1 reports]

Readme for nova-nix-0.2.0.0

[back to package description]

nova-nix

A Windows-native Nix, from scratch.

Parser, lazy evaluator, content-addressed store, derivation builder, and binary-cache substituter — in Haskell and C99. Runs natively on Windows, macOS, and Linux. No WSL, no Cygwin.

CI Hackage GHC License


Status

nova-nix evaluates real nixpkgs. import <nixpkgs> {} resolves the top-level package set (~23,000 attributes) to weak head normal form, and a package evaluates through the stdenv bootstrap down to a derivation:

$ NIX_PATH=nixpkgs=/path/to/nixpkgs \
    nova-nix eval --expr '(import <nixpkgs> { system = "x86_64-linux"; }).hello.drvPath'
"/nix/store/azg0gjls29w3sii2kjp4c1v85ka5alnp-hello-2.12.1.drv"

It targets the Nix 2.24 language. Evaluation is the milestone reached so far; confirming derivation-hash parity with upstream Nix, and building on Windows, are the work ahead.

Quickstart

git clone https://github.com/Novavero-AI/nova-nix.git
cd nova-nix
cabal build
$ nova-nix eval --expr '1 + 2'
3

$ nova-nix eval --expr 'builtins.map (x: x * x) [ 1 2 3 4 5 ]'
[ 1 4 9 16 25 ]

$ nova-nix eval FILE.nix                       # evaluate a file
$ nova-nix build FILE.nix                       # build a derivation
$ nova-nix --nix-path nixpkgs=/path eval FILE.nix

How it works

Six layers — Haskell for logic, C99 for data:

  1. Parser (Nix.Parser, Nix.Expr) — hand-rolled recursive descent; the full Nix grammar to a 19-constructor AST.
  2. Evaluator (Nix.Eval) — the AST compiles to a flat 24-opcode bytecode that a lazy, thunk-memoizing evaluator runs. Recursive let/rec are knot-tied; reference cycles are caught by blackhole detection. The evaluator is polymorphic over its effect via MonadEvalPureEval for tests, EvalIO for the real thing.
  3. Data layer (cbits/nn_*.c) — nine arena-allocated C99 modules (interned symbols, sorted attrsets, thunks, environments, lists, context strings, bytecode, lambdas) hold evaluation data off the GHC heap. Haskell calls C to create and query it; C never calls back.
  4. Store (Nix.Store) — content-addressed /nix/store (C:\nix\store on Windows) with SQLite metadata and reference scanning.
  5. Builder (Nix.Builder) — dependency graph, topological sort, and binary-cache substitution before local builds.
  6. Substituter (Nix.Substituter) — the HTTP binary-cache protocol: narinfo parsing, Ed25519 verification, NAR download and unpack. Built on nova-cache.

Two decisions shape the rest. Haskell owns evaluation, C owns data layout — bulk eval state lives off the GHC heap, so large evaluations don't thrash the collector. And derivation is a lazy wrapper over the eager derivationStrict primop (as in Nix's corepkgs/derivation.nix), so referencing a package never forces its build closure.

Windows-native

Unix assumption How nova-nix handles it
/nix/store C:\nix\store — every path is parameterized, never hardcoded
fork/exec CreateProcess via System.Process
Symlinks Developer-mode symlinks, with junction / copy fallback
260-char path limit \\?\ extended-length prefixes
A system bash the builder ships bash.exe in the store (MSYS2)

Roadmap

Done — parser, lazy bytecode evaluator, the Nix builtins set, the C99 data layer, content-addressed store, derivation builder, binary-cache substituter, and import <nixpkgs> {} evaluation through to hello.drvPath.

Next

  • Derivation-hash parity — confirm computed drvPath/outPath byte-match upstream Nix across nixpkgs.
  • Windows stdenv — MinGW GCC + MSYS2 coreutils bootstrap for native builds.
  • Substituter — XZ decompression and real NAR hashing (currently uncompressed-only, with a placeholder hash).

Library usage

import Nix.Parser (parseNix)
import Nix.Eval (PureEval (..), eval)
import Nix.Builtins (builtinEnv)

main :: IO ()
main = case parseNix "<expr>" "let x = 5; in x * 2 + 1" of
  Left err   -> print err
  Right expr -> print (runPureEval (eval (builtinEnv 0 []) expr))  -- Right (VInt 11)

The evaluator is polymorphic over MonadEval: PureEval for deterministic tests, EvalIO for filesystem access.

Build & test

cabal build
cabal test

Requires GHC 9.8+ and cabal-install 3.10+.


BSD-3-Clause · Novavero AI