summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2018-07-09 01:36:11 -0400
committerAndrew Cady <d@jerkface.net>2018-07-09 01:36:11 -0400
commit4e831c33b6360b6957c68adf50c9ecb932900b15 (patch)
tree1d299d86168650b1c721b238e9b78ffd0065365f
parent019a2a64ffd8286f2f272199bedca1d62589764a (diff)
begin config file parser
-rw-r--r--fsmgr.cabal2
-rw-r--r--fsmgr.hs24
-rw-r--r--stack.yaml1
3 files changed, 22 insertions, 5 deletions
diff --git a/fsmgr.cabal b/fsmgr.cabal
index 06a6bdb..b6b9eaa 100644
--- a/fsmgr.cabal
+++ b/fsmgr.cabal
@@ -36,7 +36,7 @@ executable fsmgr
36 ghc-options: -threaded -rtsopts -with-rtsopts=-N -W -Wall 36 ghc-options: -threaded -rtsopts -with-rtsopts=-N -W -Wall
37 build-depends: 37 build-depends:
38 base >=4.7 && <5, rebase, optparse-applicative, typed-process, 38 base >=4.7 && <5, rebase, optparse-applicative, typed-process,
39 directory, filepath, yaml, lens, lens-aeson, cryptonite, memory, basement, fsmgr 39 directory, filepath, yaml-combinators, lens, lens-aeson, cryptonite, memory, basement, fsmgr
40 default-language: Haskell2010 40 default-language: Haskell2010
41 41
42-- test-suite fsmgr-test 42-- test-suite fsmgr-test
diff --git a/fsmgr.hs b/fsmgr.hs
index 3c5e72f..71c38e0 100644
--- a/fsmgr.hs
+++ b/fsmgr.hs
@@ -1,11 +1,16 @@
1{-# LANGUAGE TypeApplications #-}
1{-# LANGUAGE InstanceSigs #-} 2{-# LANGUAGE InstanceSigs #-}
2{-# LANGUAGE NoImplicitPrelude #-} 3{-# LANGUAGE NoImplicitPrelude #-}
4{-# LANGUAGE OverloadedStrings #-}
3{-# LANGUAGE PartialTypeSignatures #-} 5{-# LANGUAGE PartialTypeSignatures #-}
4module Main where 6module Main where
5import Rebase.Prelude hiding (hash) 7import Rebase.Prelude hiding (hash, bool)
6 8
7import Crypto.Hash 9import Crypto.Hash
8import Crypto.Hash.Types.Digest.Read () 10import Crypto.Hash.Types.Digest.Read ()
11import Data.Yaml.Combinators
12import qualified Rebase.Data.Set as Set
13import qualified Rebase.Data.Vector as Vector
9 14
10{- 15{-
11 16
@@ -35,14 +40,25 @@ sha1 :: ByteString -> Digest SHA1
35sha1 = hash 40sha1 = hash
36 41
37data DiskImageConfig = DiskImageConfig { 42data DiskImageConfig = DiskImageConfig {
38 initialImage :: Either Integer (Digest SHA1) 43 initialImage :: Either Int Text -- :: Either Integer (Digest SHA1)
39, unpacked :: Set Package 44, unpacked :: Set Package
40, debconfConfig :: DebconfConfig 45, debconfConfig :: DebconfConfig
41, configured :: Set Package 46, configured :: Bool
42, patched :: [Patch] 47, patched :: Vector Text -- :: [Patch]
43} deriving (Show, Read) 48} deriving (Show, Read)
44 49
50diskImageConfigParser :: Parser DiskImageConfig
51diskImageConfigParser = object $
52 DiskImageConfig
53 <$> field "initial-image" ((Left <$> integer) <> (Right <$> string))
54 <*> (Set.fromList . toList . fmap f <$> (field "packages" (array string)))
55 <*> pure (DebconfConfig "")
56 <*> defaultField "configure" True bool
57 <*> ((fromMaybe Vector.empty) <$> (optField "patches" (array string)))
45 58
59 where
60 f :: Text -> Package
61 f = undefined
46 62
47main :: IO () 63main :: IO ()
48main = return () 64main = return ()
diff --git a/stack.yaml b/stack.yaml
index c7632a6..916aeaf 100644
--- a/stack.yaml
+++ b/stack.yaml
@@ -3,3 +3,4 @@ packages:
3- . 3- .
4extra-deps: 4extra-deps:
5- rebase-1.2.4 5- rebase-1.2.4
6- yaml-combinators-1.1.1.1