@@ -8,10 +8,13 @@ module System.Nix.Path
88 ( FilePathPart (.. )
99 , PathHashAlgo
1010 , Path (.. )
11+ , PathSet
1112 , SubstitutablePathInfo (.. )
13+ , ValidPathInfo (.. )
1214 , PathName (.. )
1315 , filePathPart
1416 , pathName
17+ , Roots
1518 ) where
1619
1720import Crypto.Hash (Digest )
@@ -23,6 +26,7 @@ import qualified Data.ByteString.Char8 as BSC
2326import Data.Hashable (Hashable (.. ), hashPtrWithSalt )
2427import Data.HashMap.Strict (HashMap )
2528import Data.HashSet (HashSet )
29+ import Data.Map.Strict (Map )
2630import Data.Text (Text )
2731import qualified Data.Text as T
2832import System.IO.Unsafe (unsafeDupablePerformIO )
@@ -53,6 +57,7 @@ type PathHashAlgo = Truncated SHA256 20
5357
5458-- | A path in a store.
5559data Path = Path ! (Digest PathHashAlgo ) ! PathName
60+ deriving (Eq , Ord , Show )
5661
5762-- | Wrapper to defined a 'Hashable' instance for 'Digest'.
5863newtype HashableDigest a = HashableDigest (Digest a )
@@ -67,18 +72,51 @@ instance Hashable Path where
6772 (HashableDigest digest) `hashWithSalt` name
6873
6974
75+ type PathSet = HashSet Path
76+
7077-- | Information about substitutes for a 'Path'.
7178data SubstitutablePathInfo = SubstitutablePathInfo
7279 { -- | The .drv which led to this 'Path'.
7380 deriver :: ! (Maybe Path )
7481 , -- | The references of the 'Path'
75- references :: ! ( HashSet Path )
82+ references :: ! PathSet
7683 , -- | The (likely compressed) size of the download of this 'Path'.
7784 downloadSize :: ! Integer
7885 , -- | The size of the uncompressed NAR serialization of this
7986 -- 'Path'.
8087 narSize :: ! Integer
81- }
88+ } deriving (Eq , Ord , Show )
89+
90+ -- | Information about 'Path'.
91+ data ValidPathInfo = ValidPathInfo
92+ { -- | Path itself
93+ path :: ! Path
94+ , -- | The .drv which led to this 'Path'.
95+ deriverVP :: ! (Maybe Path )
96+ , -- | NAR hash
97+ narHash :: ! Text
98+ , -- | The references of the 'Path'
99+ referencesVP :: ! PathSet
100+ , -- | Registration time should be time_t
101+ registrationTime :: ! Integer
102+ , -- | The size of the uncompressed NAR serialization of this
103+ -- 'Path'.
104+ narSizeVP :: ! Integer
105+ , -- | Whether the path is ultimately trusted, that is, it's a
106+ -- derivation output that was built locally.
107+ ultimate :: ! Bool
108+ , -- | Signatures
109+ sigs :: ! [Text ]
110+ , -- | Content-addressed
111+ -- Store path is computed from a cryptographic hash
112+ -- of the contents of the path, plus some other bits of data like
113+ -- the "name" part of the path.
114+ --
115+ -- ‘ca’ has one of the following forms:
116+ -- * ‘text:sha256:<sha256 hash of file contents>’ (paths by makeTextPath() / addTextToStore())
117+ -- * ‘fixed:<r?>:<ht>:<h>’ (paths by makeFixedOutputPath() / addToStore())
118+ ca :: ! Text
119+ } deriving (Eq , Ord , Show )
82120
83121-- | A valid filename or directory name
84122newtype FilePathPart = FilePathPart { unFilePathPart :: BSC. ByteString }
@@ -90,3 +128,5 @@ filePathPart :: BSC.ByteString -> Maybe FilePathPart
90128filePathPart p = case BSC. any (`elem` [' /' , ' \NUL ' ]) p of
91129 False -> Just $ FilePathPart p
92130 True -> Nothing
131+
132+ type Roots = Map Path Path
0 commit comments