@@ -8,10 +8,13 @@ module System.Nix.Path
8
8
( FilePathPart (.. )
9
9
, PathHashAlgo
10
10
, Path (.. )
11
+ , PathSet
11
12
, SubstitutablePathInfo (.. )
13
+ , ValidPathInfo (.. )
12
14
, PathName (.. )
13
15
, filePathPart
14
16
, pathName
17
+ , Roots
15
18
) where
16
19
17
20
import Crypto.Hash (Digest )
@@ -23,6 +26,7 @@ import qualified Data.ByteString.Char8 as BSC
23
26
import Data.Hashable (Hashable (.. ), hashPtrWithSalt )
24
27
import Data.HashMap.Strict (HashMap )
25
28
import Data.HashSet (HashSet )
29
+ import Data.Map.Strict (Map )
26
30
import Data.Text (Text )
27
31
import qualified Data.Text as T
28
32
import System.IO.Unsafe (unsafeDupablePerformIO )
@@ -53,6 +57,7 @@ type PathHashAlgo = Truncated SHA256 20
53
57
54
58
-- | A path in a store.
55
59
data Path = Path ! (Digest PathHashAlgo ) ! PathName
60
+ deriving (Eq , Ord , Show )
56
61
57
62
-- | Wrapper to defined a 'Hashable' instance for 'Digest'.
58
63
newtype HashableDigest a = HashableDigest (Digest a )
@@ -67,18 +72,51 @@ instance Hashable Path where
67
72
(HashableDigest digest) `hashWithSalt` name
68
73
69
74
75
+ type PathSet = HashSet Path
76
+
70
77
-- | Information about substitutes for a 'Path'.
71
78
data SubstitutablePathInfo = SubstitutablePathInfo
72
79
{ -- | The .drv which led to this 'Path'.
73
80
deriver :: ! (Maybe Path )
74
81
, -- | The references of the 'Path'
75
- references :: ! ( HashSet Path )
82
+ references :: ! PathSet
76
83
, -- | The (likely compressed) size of the download of this 'Path'.
77
84
downloadSize :: ! Integer
78
85
, -- | The size of the uncompressed NAR serialization of this
79
86
-- 'Path'.
80
87
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 )
82
120
83
121
-- | A valid filename or directory name
84
122
newtype FilePathPart = FilePathPart { unFilePathPart :: BSC. ByteString }
@@ -90,3 +128,5 @@ filePathPart :: BSC.ByteString -> Maybe FilePathPart
90
128
filePathPart p = case BSC. any (`elem` [' /' , ' \NUL ' ]) p of
91
129
False -> Just $ FilePathPart p
92
130
True -> Nothing
131
+
132
+ type Roots = Map Path Path
0 commit comments