hn.today

Nixpkgs for the Front End Impaired

fzakaria.com6 points0 comments
Screenshot of Nixpkgs for the Front End Impaired

jinx is a transpiler that converts Nix expressions into TypeScript modules and has been used to compile the entire nixpkgs tree - 231,777 attributes - into a TypeScript program. Each .nix file becomes a .ts module that preserves Nix semantics (including laziness via explicit thunks) so that evaluating an attribute in Node or a browser produces the exact same .drv and drvPath strings that Nix would generate. The system writes nothing to /nix/store during evaluation; jinx can instantiate .drv closures and hand them to nix-store realize for building. The compiled tree is published, and the runtime runs on Node 24 or in browsers with no native dependencies.

Verification shows strong fidelity: across x86_64-linux, aarch64-linux and aarch64-darwin, 229,063 attributes produced identical drvPaths, with 2,714 failing on both sides due to attributes Nix refuses to evaluate. Performance is slower - warm evaluations ~2.5-5× slower and cold runs 3-10× slower, with 2-4× higher memory use because of thunk overhead - but usable. The TypeScript representation unlocks practical benefits: V8 profiling and flamegraphs, LSP-powered editor completion and type checking, source-mapped breakpoints for stepping through Nix, unit testing, writing interoperable packages in TypeScript, and in-browser exploration. The source and compiled nixpkgs tree are on GitHub; the author notes AI-assisted coding in the implementation.

Read on fzakaria.com0 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in Programming

Recreational Programming

Recreational Programming

Recreational programming is driven by curiosity and intrinsic motivation, focusing on enjoyment rather than external goals like career advancement or profit. It encompasses diverse styles such as exploring new languages, artistic coding, and building for fun, emphasizing learning, creativity, and personal growth. (cphiri.dev)

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.