Skip to content

Commit 561fda5

Browse files
committed
ReadonlyStoreEffects: Add subtistutable path info query
1 parent ead4332 commit 561fda5

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

hnix-store-core/src/System/Nix/Store.hs

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module System.Nix.Store
88
( PathName, pathNameContents, pathName
99
, PathHashAlgo, Path(..)
1010
, ReadonlyStoreEffects(..)
11+
, SubstitutablePathInfo(..)
1112
) where
1213

1314
import Crypto.Hash (Digest)
@@ -19,6 +20,7 @@ import Text.Regex.Base.RegexLike (makeRegex, matchTest)
1920
import Text.Regex.TDFA.Text (Regex)
2021
import Data.Hashable (Hashable(..), hashPtrWithSalt)
2122
import Data.HashSet (HashSet)
23+
import Data.HashMap.Strict (HashMap)
2224
import System.IO.Unsafe (unsafeDupablePerformIO)
2325

2426
-- | The name portion of a Nix path.
@@ -58,19 +60,32 @@ instance Hashable Path where
5860
s `hashWithSalt`
5961
(HashableDigest digest) `hashWithSalt` name
6062

63+
-- | Information about substitutes for a 'Path'.
64+
data SubstitutablePathInfo = SubstitutablePathInfo
65+
{ -- | The .drv which led to this 'Path'.
66+
deriver :: !(Maybe Path)
67+
, -- | The references of the 'Path'
68+
references :: !(HashSet Path)
69+
, -- | The (likely compressed) size of the download of this 'Path'.
70+
downloadSize :: !Integer
71+
, -- | The size of the uncompressed NAR serialization of this
72+
-- 'Path'.
73+
narSize :: !Integer
74+
}
75+
6176
-- | Read-only interactions with a store.
6277
--
63-
-- 'rootedPath': A path plus a witness to the fact that the path is
78+
-- @rootedPath@: A path plus a witness to the fact that the path is
6479
-- reachable from a root whose liftime is at least as long as the
65-
-- 'rootedPath' reference itself, when the implementation supports
80+
-- @rootedPath@ reference itself, when the implementation supports
6681
-- this.
6782
--
68-
-- 'validPath': A 'rootedPath' plus a witness to the fact that the
83+
-- @validPath@: A @rootedPath@ plus a witness to the fact that the
6984
-- path is valid. On implementations that support temporary roots,
7085
-- this implies that the path will remain valid so long as the
7186
-- reference is held.
7287
--
73-
-- 'm': The monad the effects operate in.
88+
-- @m@: The monad the effects operate in.
7489
data ReadonlyStoreEffects rootedPath validPath m =
7590
ReadonlyStoreEffects
7691
{ -- | Project out the underlying 'Path' from a 'rootedPath'
@@ -83,4 +98,7 @@ data ReadonlyStoreEffects rootedPath validPath m =
8398
referrers :: !(validPath -> m (HashSet Path))
8499
, -- | Get a root to the 'Path'.
85100
rootedPath :: !(Path -> m rootedPath)
101+
, -- | Get information about substituters of a set of 'Path's
102+
substitutablePathInfos ::
103+
!(HashSet Path -> m (HashMap Path SubstitutablePathInfo))
86104
}

0 commit comments

Comments
 (0)