libnix-0.2.0.0: Bindings to the nix package manager

CopyrightProfpatsch 2016–2018
LicenseGPL-3
Stabilityexperimental
Portabilitynix 1.11.x, nix 2.0
Safe HaskellNone
LanguageHaskell2010

Foreign.Nix.Shellout

Contents

Description

Calls to the nix command line to convert textual nix expressions to derivations & realized storepaths.

Synopsis

Calling nix

Parse

parseNixExpr :: Text -> NixAction ParseError NixExpr Source #

Parse a nix expression and check for syntactic validity.

data ParseError Source #

Constructors

SyntaxError Text

the input string was not a syntactically valid nix expression

UnknownParseError

catch-all error

Instances
Eq ParseError Source # 
Instance details

Defined in Foreign.Nix.Shellout

Show ParseError Source # 
Instance details

Defined in Foreign.Nix.Shellout

Instantiate

instantiate :: NixExpr -> NixAction InstantiateError (StorePath Derivation) Source #

Instantiate a parsed expression into a derivation.

data InstantiateError Source #

Constructors

NotADerivation

the given expression does not evaluate to a derivaton

UnknownInstantiateError

catch-all error

eval :: NixExpr -> NixAction InstantiateError () Source #

Just tests if the expression can be evaluated. That doesn’t mean it has to instantiate however.

Realize

realize :: StorePath Derivation -> NixAction RealizeError (StorePath Realized) Source #

Finally derivations are realized into full store outputs. This will typically take a while so it should be executed asynchronously.

Helpers

addToStore :: FilePath -> NixAction RealizeError (StorePath Realized) Source #

Copy the given file or folder to the nix store and return it’s path.

parseInstRealize :: Text -> NixAction NixError (StorePath Realized) Source #

A convenience function to directly realize a nix expression. Any errors are put into a combined error type.

data NixError Source #

Combines all error types that could happen.

Instances
Eq NixError Source # 
Instance details

Defined in Foreign.Nix.Shellout

Show NixError Source # 
Instance details

Defined in Foreign.Nix.Shellout

Types

data StorePath a Source #

A path in the nix store. It carries a phantom a to differentiate between Derivation files and Realized paths.

Instances
Eq (StorePath a) Source # 
Instance details

Defined in Foreign.Nix.Shellout.Types

Methods

(==) :: StorePath a -> StorePath a -> Bool #

(/=) :: StorePath a -> StorePath a -> Bool #

Show (StorePath a) Source # 
Instance details

Defined in Foreign.Nix.Shellout.Types

data Derivation Source #

A nix derivation is a complete build instruction that can be realized.

data Realized Source #

Once a derivation is realized, the finished output can be used.

data NixExpr Source #

A sucessfully parsed nix expression.

Instances
Eq NixExpr Source # 
Instance details

Defined in Foreign.Nix.Shellout

Methods

(==) :: NixExpr -> NixExpr -> Bool #

(/=) :: NixExpr -> NixExpr -> Bool #

Show NixExpr Source # 
Instance details

Defined in Foreign.Nix.Shellout

runNixAction :: NixAction e a -> IO (Either (Text, e) a) Source #

Run a NixAction without having to go through ExceptT first.

newtype NixAction e a Source #

Calls a command that returns an error and the whole stderr on failure.

Constructors

NixAction 

Fields

Instances
Bifunctor NixAction Source # 
Instance details

Defined in Foreign.Nix.Shellout.Types

Methods

bimap :: (a -> b) -> (c -> d) -> NixAction a c -> NixAction b d #

first :: (a -> b) -> NixAction a c -> NixAction b c #

second :: (b -> c) -> NixAction a b -> NixAction a c #

Monad (NixAction e) Source # 
Instance details

Defined in Foreign.Nix.Shellout.Types

Methods

(>>=) :: NixAction e a -> (a -> NixAction e b) -> NixAction e b #

(>>) :: NixAction e a -> NixAction e b -> NixAction e b #

return :: a -> NixAction e a #

fail :: String -> NixAction e a #

Functor (NixAction e) Source # 
Instance details

Defined in Foreign.Nix.Shellout.Types

Methods

fmap :: (a -> b) -> NixAction e a -> NixAction e b #

(<$) :: a -> NixAction e b -> NixAction e a #

Applicative (NixAction e) Source # 
Instance details

Defined in Foreign.Nix.Shellout.Types

Methods

pure :: a -> NixAction e a #

(<*>) :: NixAction e (a -> b) -> NixAction e a -> NixAction e b #

liftA2 :: (a -> b -> c) -> NixAction e a -> NixAction e b -> NixAction e c #

(*>) :: NixAction e a -> NixAction e b -> NixAction e b #

(<*) :: NixAction e a -> NixAction e b -> NixAction e a #

MonadIO (NixAction e) Source # 
Instance details

Defined in Foreign.Nix.Shellout.Types

Methods

liftIO :: IO a -> NixAction e a #