libnix: Bindings to the nix package manager

[ foreign, gpl, library, nix ] [ Propose Tags ]

Use the nix package manager from Haskell. All modules are designed to be imported qualified.


[Skip to Readme]
Versions 0.2.0.0, 0.2.0.1
Dependencies aeson (>=1.0.0.0 && <1.5.0.0), base (>=4.9 && <5), errors (>=2.2.0 && <2.4.0), filepath, process, protolude (==0.2.*), text [details]
License GPL-3.0-only
Author Profpatsch
Maintainer mail@profpatsch.de
Category Foreign, Nix
Home page https://github.com/Profpatsch/libnix-haskell#readme
Bug tracker https://github.com/Profpatsch/libnix-haskell/issues
Source repo head: git clone https://github.com/Profpatsch/libnix-haskell
Uploaded by Profpatsch at Sat Aug 11 22:13:08 UTC 2018
Distributions NixOS:0.2.0.1
Downloads 70 total (9 in the last 30 days)
Rating 1.75 (votes: 1) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2018-08-11 [all 1 reports]
Hackage Matrix CI

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


Readme for libnix-0.2.0.1

[back to package description]

libnix

Haskell bindings to the nix package manager

This project aims to provide an interface to call nix functionality from the safe haven that is Haskell. As much type safety as possible should be guaranteed to the user.

The project consists of two broad steps:

  1. bindings to the command line tools
  2. bindings to the nix libraries themselves

At the moment, an beta version of 1. is implemented, together with a small number of tests to check for possible changes in the interface, which consists mainly of three functions:

parseNixExpr :: Text                 -> NixAction ParseError NixExpr
instantiate  :: NixExpr              -> NixAction InstantiateError (StorePath Derivation)
realize      :: StorePath Derivation -> NixAction RealizeError (StorePath Realized)

which do what you’d expect; and two helper functions

eval             :: NixExpr -> NixAction InstantiateError ()
parseInstRealize :: Text    -> NixAction NixError (StorePath Realized)

where parseInstRealize performs all three steps at once.

Nix Prefetch Wrappers

We implement an additional module that creates nicely typed wrappers for nix-prefetch-X tools, please see the module documentation what is supported exactly.

url :: UrlOptions -> NixAction PrefetchError (Sha256, StorePath Realized)
git :: GitOptions -> NixAction PrefetchError GitOutput

C++ bindings

The second steps would be to directly bind into the C++ library. That could either mean writing a C wrapper and using Haskell’s native FFI, or generating bindings with Hoppy, which we’d prefer. Hoppy would need to be able to handle C++ exceptions first, though.

Other nix libraries on hackage

  • cabal2nix: the executable at the base of nix haskell support
  • language-nix: library cabal2nix uses to generate its nix files
  • hnix: a project to implement the nix expression language in haskell
  • nix-eval: runtime eval of Haskell code using nix
  • simple-nix: looks like a nix parser, but not entirely sure

It doesn’t look like the scope of libnix collides with any of these packages.