MyNixOS website logo
Description

Bindings to the nix package manager.

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

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.

Metadata

Version

0.4.1.0

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows