packages feed

nix-derivation 1.0.2 → 1.1.0

raw patch · 5 files changed

+64/−62 lines, 5 filesdep +filepathdep −system-filepathdep ~QuickCheckdep ~pretty-showPVP ok

version bump matches the API change (PVP)

Dependencies added: filepath

Dependencies removed: system-filepath

Dependency ranges changed: QuickCheck, pretty-show

API changes (from Hackage documentation)

- Nix.Derivation: Derivation :: Map Text DerivationOutput -> Map FilePath (Set Text) -> Set FilePath -> Text -> Text -> Vector Text -> Map Text Text -> Derivation
+ Nix.Derivation: Derivation :: Map txt (DerivationOutput fp txt) -> Map fp (Set txt) -> Set fp -> txt -> txt -> Vector txt -> Map txt txt -> Derivation fp txt
- Nix.Derivation: DerivationOutput :: FilePath -> Text -> Text -> DerivationOutput
+ Nix.Derivation: DerivationOutput :: fp -> txt -> txt -> DerivationOutput fp txt
- Nix.Derivation: [args] :: Derivation -> Vector Text
+ Nix.Derivation: [args] :: Derivation fp txt -> Vector txt
- Nix.Derivation: [builder] :: Derivation -> Text
+ Nix.Derivation: [builder] :: Derivation fp txt -> txt
- Nix.Derivation: [env] :: Derivation -> Map Text Text
+ Nix.Derivation: [env] :: Derivation fp txt -> Map txt txt
- Nix.Derivation: [hashAlgo] :: DerivationOutput -> Text
+ Nix.Derivation: [hashAlgo] :: DerivationOutput fp txt -> txt
- Nix.Derivation: [hash] :: DerivationOutput -> Text
+ Nix.Derivation: [hash] :: DerivationOutput fp txt -> txt
- Nix.Derivation: [inputDrvs] :: Derivation -> Map FilePath (Set Text)
+ Nix.Derivation: [inputDrvs] :: Derivation fp txt -> Map fp (Set txt)
- Nix.Derivation: [inputSrcs] :: Derivation -> Set FilePath
+ Nix.Derivation: [inputSrcs] :: Derivation fp txt -> Set fp
- Nix.Derivation: [outputs] :: Derivation -> Map Text DerivationOutput
+ Nix.Derivation: [outputs] :: Derivation fp txt -> Map txt (DerivationOutput fp txt)
- Nix.Derivation: [path] :: DerivationOutput -> FilePath
+ Nix.Derivation: [path] :: DerivationOutput fp txt -> fp
- Nix.Derivation: [platform] :: Derivation -> Text
+ Nix.Derivation: [platform] :: Derivation fp txt -> txt
- Nix.Derivation: buildDerivation :: Derivation -> Builder
+ Nix.Derivation: buildDerivation :: Derivation FilePath Text -> Builder
- Nix.Derivation: data Derivation
+ Nix.Derivation: data Derivation fp txt
- Nix.Derivation: data DerivationOutput
+ Nix.Derivation: data DerivationOutput fp txt
- Nix.Derivation: parseDerivation :: Parser Derivation
+ Nix.Derivation: parseDerivation :: Parser (Derivation FilePath Text)

Files

nix-derivation.cabal view
@@ -1,8 +1,8 @@ Name: nix-derivation-Version: 1.0.2+Version: 1.1.0 Cabal-Version: >=1.10 Build-Type: Simple-Tested-With: GHC == 7.8.4, GHC == 7.10.3, GHC == 8.0.2+Tested-With: GHC == 7.8.4, GHC == 7.10.3, GHC == 8.0.2, GHC == 8.8.3 License: BSD3 License-File: LICENSE Copyright: 2017 Gabriel Gonzalez@@ -32,9 +32,9 @@         attoparsec      >= 0.12.0.0 && < 0.14,         containers                     < 0.7 ,         deepseq         >= 1.4.0.0  && < 1.5 ,-        system-filepath >= 0.3.1    && < 0.5 ,         text            >= 0.8.0.0  && < 1.3 ,-        vector                         < 0.13+        vector                         < 0.13,+        filepath                       < 1.5     Exposed-Modules:         Nix.Derivation     Other-Modules:@@ -49,7 +49,7 @@     Build-Depends:         base           >= 4.6.0.0  && < 5   ,         attoparsec     >= 0.12.0.0 && < 0.14,-        pretty-show    >= 1.6.11   && < 1.10,+        pretty-show    >= 1.6.11   && < 1.11,         text           >= 0.8.0.0  && < 1.3 ,         nix-derivation     GHC-Options: -Wall@@ -77,10 +77,10 @@         base            >= 4.6.0.0  && < 5   ,         attoparsec      >= 0.12.0.0 && < 0.14,         nix-derivation                       ,-        QuickCheck                     < 2.13,-        system-filepath >= 0.3.1    && < 0.5 ,+        QuickCheck                     < 2.14,         text            >= 0.8.0.0  && < 1.3 ,-        vector                         < 0.13+        vector                         < 0.13,+        filepath                       < 1.5  Benchmark benchmark     Default-Language: Haskell2010
src/Nix/Derivation/Builder.hs view
@@ -6,29 +6,33 @@ module Nix.Derivation.Builder     ( -- * Builder       buildDerivation+    , buildDerivationWith     ) where -import Data.Foldable (foldMap) import Data.Map (Map)-import Data.Monoid ((<>)) import Data.Set (Set) import Data.Text (Text) import Data.Text.Lazy.Builder (Builder) import Data.Vector (Vector)-import Filesystem.Path.CurrentOS (FilePath) import Nix.Derivation.Types (Derivation(..), DerivationOutput(..))-import Prelude hiding (FilePath)  import qualified Data.Map import qualified Data.Set import qualified Data.Text import qualified Data.Text.Lazy.Builder import qualified Data.Vector-import qualified Filesystem.Path.CurrentOS  -- | Render a derivation as a `Builder`-buildDerivation :: Derivation -> Builder-buildDerivation (Derivation {..}) =+buildDerivation :: Derivation FilePath Text -> Builder+buildDerivation = buildDerivationWith filepath' string'++-- | Render a derivation as a `Builder` using custom+-- renderer for filepath and string+buildDerivationWith :: (fp -> Builder)+                    -> (txt -> Builder)+                    -> Derivation fp txt+                    -> Builder+buildDerivationWith filepath string (Derivation {..}) =         "Derive("     <>  mapOf keyValue0 outputs     <>  ","@@ -89,12 +93,8 @@ vectorOf :: (a -> Builder) -> Vector a -> Builder vectorOf element xs = listOf element (Data.Vector.toList xs) -string :: Text -> Builder-string = Data.Text.Lazy.Builder.fromText . Data.Text.pack . show+string' :: Text -> Builder+string' = Data.Text.Lazy.Builder.fromText . Data.Text.pack . show -filepath :: FilePath -> Builder-filepath p = string text-  where-    text = case Filesystem.Path.CurrentOS.toText p of-        Left  t -> t-        Right t -> t+filepath' :: FilePath -> Builder+filepath' p = string' $ Data.Text.pack p
src/Nix/Derivation/Parser.hs view
@@ -8,17 +8,15 @@ module Nix.Derivation.Parser     ( -- * Parser       parseDerivation+    , parseDerivationWith     ) where  import Data.Attoparsec.Text.Lazy (Parser) import Data.Map (Map)-import Data.Monoid ((<>)) import Data.Set (Set) import Data.Text (Text) import Data.Vector (Vector) import Nix.Derivation.Types (Derivation(..), DerivationOutput(..))-import Prelude hiding (FilePath)-import Filesystem.Path.CurrentOS (FilePath)  import qualified Data.Attoparsec.Text.Lazy import qualified Data.Map@@ -26,7 +24,7 @@ import qualified Data.Text import qualified Data.Text.Lazy import qualified Data.Vector-import qualified Filesystem.Path.CurrentOS+import qualified System.FilePath  listOf :: Parser a -> Parser [a] listOf element = do@@ -36,8 +34,13 @@     return es  -- | Parse a derivation-parseDerivation :: Parser Derivation-parseDerivation = do+parseDerivation :: Parser (Derivation FilePath Text)+parseDerivation = parseDerivationWith filepathParser textParser++-- | Parse a derivation using custom+-- parsers for filepaths and text fields+parseDerivationWith :: (Ord fp, Ord txt) => Parser fp -> Parser txt -> Parser (Derivation fp txt)+parseDerivationWith filepath string = do     "Derive("      let keyValue0 = do@@ -95,8 +98,8 @@      return (Derivation {..}) -string :: Parser Text-string = do+textParser :: Parser Text+textParser = do     "\""     let predicate c = not (c == '"' || c == '\\')     let loop = do@@ -117,12 +120,13 @@     text <- loop     return (Data.Text.Lazy.toStrict text) -filepath :: Parser FilePath-filepath = do-    text <- string-    case Data.Text.uncons text of-        Just ('/', _) -> do-            return (Filesystem.Path.CurrentOS.fromText text)+filepathParser :: Parser FilePath+filepathParser = do+    text <- textParser+    let str = Data.Text.unpack text+    case (Data.Text.uncons text, System.FilePath.isValid str) of+        (Just ('/', _), True) -> do+            return str         _ -> do             fail ("bad path ‘" <> Data.Text.unpack text <> "’ in derivation") 
src/Nix/Derivation/Types.hs view
@@ -1,4 +1,7 @@ {-# LANGUAGE DeriveGeneric  #-}+{-# LANGUAGE DeriveFunctor  #-}+{-# LANGUAGE FlexibleInstances  #-}+{-# LANGUAGE KindSignatures  #-}  -- | Shared types @@ -11,42 +14,39 @@ import Control.DeepSeq (NFData) import Data.Map (Map) import Data.Set (Set)-import Data.Text (Text) import Data.Vector (Vector)-import Filesystem.Path.CurrentOS (FilePath) import GHC.Generics (Generic)-import Prelude hiding (FilePath)  -- | A Nix derivation-data Derivation = Derivation-    { outputs   :: Map Text DerivationOutput+data Derivation fp txt = Derivation+    { outputs   :: Map txt (DerivationOutput fp txt)     -- ^ Outputs produced by this derivation where keys are output names-    , inputDrvs :: Map FilePath (Set Text)+    , inputDrvs :: Map fp (Set txt)     -- ^ Inputs that are derivations where keys specify derivation paths and     -- values specify which output names are used by this derivation-    , inputSrcs :: Set FilePath+    , inputSrcs :: Set fp     -- ^ Inputs that are sources-    , platform  :: Text+    , platform  :: txt     -- ^ Platform required for this derivation-    , builder   :: Text+    , builder   :: txt     -- ^ Code to build the derivation, which can be a path or a builtin function-    , args      :: Vector Text+    , args      :: Vector txt     -- ^ Arguments passed to the executable used to build to derivation-    , env       :: Map Text Text+    , env       :: Map txt txt     -- ^ Environment variables provided to the executable used to build the     -- derivation     } deriving (Eq, Generic, Ord, Show) -instance NFData Derivation+instance (NFData a, NFData b) => NFData (Derivation a b)  -- | An output of a Nix derivation-data DerivationOutput = DerivationOutput-    { path     :: FilePath+data DerivationOutput fp txt = DerivationOutput+    { path     :: fp     -- ^ Path where the output will be saved-    , hashAlgo :: Text+    , hashAlgo :: txt     -- ^ Hash used for expected hash computation-    , hash     :: Text+    , hash     :: txt     -- ^ Expected hash     } deriving (Eq, Generic, Ord, Show) -instance NFData DerivationOutput+instance (NFData a, NFData b) => NFData (DerivationOutput a b)
tests/Property.hs view
@@ -1,4 +1,6 @@ {-# LANGUAGE RecordWildCards #-}+{-# LANGUAGE TypeSynonymInstances #-}+{-# LANGUAGE FlexibleInstances #-}  {-# OPTIONS_GHC -fno-warn-orphans #-} @@ -6,7 +8,7 @@  import Data.Text (Text) import Data.Vector (Vector)-import Filesystem.Path.CurrentOS (FilePath)+import System.FilePath import Nix.Derivation (Derivation(..), DerivationOutput(..)) import Prelude hiding (FilePath, either) import Test.QuickCheck (Arbitrary(..))@@ -15,27 +17,23 @@ import qualified Data.Text import qualified Data.Text.Lazy.Builder import qualified Data.Vector-import qualified Filesystem.Path.CurrentOS import qualified Nix.Derivation import qualified Test.QuickCheck  instance Arbitrary Text where     arbitrary = fmap Data.Text.pack arbitrary -instance Arbitrary FilePath where-    arbitrary = fmap Filesystem.Path.CurrentOS.decodeString arbitrary- instance Arbitrary a => Arbitrary (Vector a) where     arbitrary = fmap Data.Vector.fromList arbitrary -instance Arbitrary DerivationOutput where+instance Arbitrary (DerivationOutput FilePath Text) where     arbitrary = do         path     <- arbitrary         hashAlgo <- arbitrary         hash     <- arbitrary         return (DerivationOutput {..}) -instance Arbitrary Derivation where+instance Arbitrary (Derivation FilePath Text) where     arbitrary = do         outputs   <- arbitrary         inputDrvs <- arbitrary@@ -46,7 +44,7 @@         env       <- arbitrary         return (Derivation {..}) -property :: Derivation -> Bool+property :: Derivation FilePath Text -> Bool property derivation0 = either == Right derivation0   where     builder = Nix.Derivation.buildDerivation derivation0