module System.Nix.Derivation
  ( parseDerivation
  , buildDerivation
  )
where

import qualified Data.Text.Lazy.Builder        as Text.Lazy
                                                ( Builder )
import qualified Data.Attoparsec.Text.Lazy     as Text.Lazy
                                                ( Parser )
import           Nix.Derivation                 ( Derivation )
import qualified Nix.Derivation                as Derivation
import           System.Nix.StorePath           ( StorePath )
import qualified System.Nix.StorePath          as StorePath



parseDerivation :: FilePath -> Text.Lazy.Parser (Derivation StorePath Text)
parseDerivation :: String -> Parser (Derivation StorePath Text)
parseDerivation String
expectedRoot =
  forall fp txt.
(Ord fp, Ord txt) =>
Parser fp -> Parser txt -> Parser (Derivation fp txt)
Derivation.parseDerivationWith
    (Parser Text Text
"\"" forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> String -> Parser Text StorePath
StorePath.pathParser String
expectedRoot forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* Parser Text Text
"\"")
    Parser Text Text
Derivation.textParser

buildDerivation :: Derivation StorePath Text -> Text.Lazy.Builder
buildDerivation :: Derivation StorePath Text -> Builder
buildDerivation =
  forall fp txt.
(fp -> Builder) -> (txt -> Builder) -> Derivation fp txt -> Builder
Derivation.buildDerivationWith
    (forall b a. (Show a, IsString b) => a -> b
show forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall b a. (Show a, IsString b) => a -> b
show)
    forall b a. (Show a, IsString b) => a -> b
show