Skip to content

Commit b74a691

Browse files
committed
Add a local binary store
Same as using file://$DIRECTORY
1 parent 59d5c28 commit b74a691

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

hnix-store-binary/hnix-store-binary.cabal

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@ cabal-version: >=1.10
1515

1616
library
1717
exposed-modules: System.Nix.Store.Binary
18+
, System.Nix.Store.Binary.Local
1819

1920
build-depends: base >=4.10 && <4.12
2021
, binary
2122
, bytestring
23+
, directory
24+
, filepath
2225
, lzma
2326
, mtl
2427
, text
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{-|
2+
Description : Interact with a local binary Nix store.
3+
Maintainer : Brian McKenna <[email protected]>
4+
-}
5+
module System.Nix.Store.Binary.Local (
6+
localBinaryStoreEffects
7+
) where
8+
9+
import Control.Monad.Trans (MonadIO(..))
10+
import System.Directory
11+
import System.FilePath
12+
import System.Nix.Store.Binary
13+
import qualified Data.ByteString as BS
14+
import qualified Data.Text as T
15+
16+
localBinaryStoreEffects
17+
:: (MonadIO m)
18+
=> FilePath
19+
-> BinaryStoreEffects m
20+
localBinaryStoreEffects cacheDir =
21+
BinaryStoreEffects upsertFile'
22+
where
23+
upsertFile' pth d _ = liftIO $ do
24+
let pth' = cacheDir </> T.unpack pth
25+
createDirectoryIfMissing True $ takeDirectory pth'
26+
BS.writeFile pth' d

0 commit comments

Comments
 (0)