|
| 1 | +{-| |
| 2 | +Description : Types and effects for interacting with the Nix store. |
| 3 | +Maintainer : Shea Levy <[email protected]> |
| 4 | +-} |
| 5 | +{-# LANGUAGE DataKinds #-} |
| 6 | +{-# LANGUAGE GeneralizedNewtypeDeriving #-} |
| 7 | +module System.Nix.ValidPath |
| 8 | + ( ValidPath(..) |
| 9 | + ) where |
| 10 | + |
| 11 | +import System.Nix.Hash (Digest(..), |
| 12 | + HashAlgorithm(Truncated, SHA256)) |
| 13 | +import System.Nix.Path (Path(..), PathSet) |
| 14 | +import qualified Data.ByteString as BS |
| 15 | +import qualified Data.ByteString.Char8 as BSC |
| 16 | +import Data.Hashable (Hashable (..), hashPtrWithSalt) |
| 17 | +import Data.HashMap.Strict (HashMap) |
| 18 | +import Data.HashSet (HashSet) |
| 19 | +import Data.Map.Strict (Map) |
| 20 | +import Data.Text (Text) |
| 21 | +import Data.Time (UTCTime) |
| 22 | +import qualified Data.Text as T |
| 23 | +import System.IO.Unsafe (unsafeDupablePerformIO) |
| 24 | +import Text.Regex.Base.RegexLike (makeRegex, matchTest) |
| 25 | +import Text.Regex.TDFA.Text (Regex) |
| 26 | + |
| 27 | +-- | Information about @Path@ |
| 28 | +data ValidPath = ValidPath |
| 29 | + { -- | Path itself |
| 30 | + path :: !Path |
| 31 | + , -- | The .drv which led to this 'Path'. |
| 32 | + deriver :: !(Maybe Path) |
| 33 | + , -- | NAR hash |
| 34 | + narHash :: !Text |
| 35 | + , -- | The references of the 'Path' |
| 36 | + references :: !PathSet |
| 37 | + , -- | Registration time |
| 38 | + registrationTime :: !UTCTime |
| 39 | + , -- | The size of the uncompressed NAR serialization of this |
| 40 | + -- 'Path'. |
| 41 | + narSize :: !Integer |
| 42 | + , -- | Whether the path is ultimately trusted, that is, it's a |
| 43 | + -- derivation output that was built locally. |
| 44 | + ultimate :: !Bool |
| 45 | + , -- | Signatures |
| 46 | + sigs :: ![Text] |
| 47 | + , -- | Content-addressed |
| 48 | + -- Store path is computed from a cryptographic hash |
| 49 | + -- of the contents of the path, plus some other bits of data like |
| 50 | + -- the "name" part of the path. |
| 51 | + -- |
| 52 | + -- ‘ca’ has one of the following forms: |
| 53 | + -- * ‘text:sha256:<sha256 hash of file contents>’ (paths by makeTextPath() / addTextToStore()) |
| 54 | + -- * ‘fixed:<r?>:<ht>:<h>’ (paths by makeFixedOutputPath() / addToStore()) |
| 55 | + ca :: !Text |
| 56 | + } deriving (Eq, Ord, Show) |
0 commit comments