@@ -9,6 +9,8 @@ Description : Representation of Nix store paths.
99module System.Nix.StorePath
1010 ( -- * Basic store path types
1111 StoreDir (.. )
12+ , HasStoreDir (.. )
13+ , getStoreDir
1214 , StorePath (.. )
1315 , StorePathName (.. )
1416 , StorePathHashPart (.. )
@@ -33,6 +35,7 @@ module System.Nix.StorePath
3335#if !MIN_VERSION_base(4,18,0)
3436import Control.Applicative (liftA2 )
3537#endif
38+ import Control.Monad.Reader.Class (MonadReader , asks )
3639import Crypto.Hash (HashAlgorithm , SHA256 )
3740import Data.Attoparsec.Text.Lazy (Parser , (<?>) )
3841import Data.ByteString (ByteString )
@@ -189,6 +192,13 @@ instance Arbitrary StoreDir where
189192instance Default StoreDir where
190193 def = StoreDir " /nix/store"
191194
195+ class HasStoreDir r where
196+ hasStoreDir :: r -> StoreDir
197+
198+ -- | Ask for a @StoreDir@
199+ getStoreDir :: (HasStoreDir r , MonadReader r m ) => m StoreDir
200+ getStoreDir = asks hasStoreDir
201+
192202-- | Render a 'StorePath' as a 'RawFilePath'.
193203storePathToRawFilePath :: StoreDir -> StorePath -> RawFilePath
194204storePathToRawFilePath storeDir StorePath {.. } =
0 commit comments