Home

Awesome

hnix-store

GitHub Workflow Status

A Haskell interface to the Nix store.

Rationale

Nix can conceptually be broken up into two layers, both (perhaps unfortunately) named "Nix": The expression language and the store. The semantics of the expression language fundamentally depend on the store, but the store is independent of the language. The store semantics provide the basic building blocks of Nix: content-addressed files and directories, the drv file format and the semantics for building drvs, tracking references of store paths, copying files between stores (or to/from caches), distributed builds, etc.

The goal of hnix-store is to provide a Haskell interface to the Nix store semantics, as well as various implementations of that interface. Though the current primary client is hnix, an effort to reimplement the Nix expression language in Haskell, this project is meant to be generic and could be used for a number of other cases of interaction with the Nix store (e.g. a shake backend that emitted each build action as a store derivation). Currently, there are three implementations planned:

Packages

In the interest of separating concerns, this project is split into several Haskell packages.

hnix-store-core

Hackage version Dependencies

Contains the core types and fundamental operations, agnostic to any particular effectful implementation (e.g. in-memory, talking to the Nix daemon in IO, etc.), with the actual implementations in a different package.

The intent is that core business logic for a project that needs to interact with the Nix store can simply depend on hnix-store-core, and only at the very edges of the system would it be necessary to bring in a specific implementation.

hnix-store-db

Hackage version Dependencies

Implementation of the Nix store SQLite database.

hnix-store-json

Hackage version Dependencies

Aeson instances for core types, required for remote store protocol.

hnix-store-nar

Hackage version Dependencies

Packing and unpacking for NAR file format used by Nix.

hnix-store-readonly

Hackage version Dependencies

Path computation without interaction with the actual Nix store

hnix-store-remote

Hackage version Dependencies

Nix worker protocol implementation for interacting with remote Nix store via nix-daemon.

hnix-store-tests

Hackage version Dependencies

Aribtrary instances and utilities for testing.