Skip to content

Commit

Permalink
Add a local binary store
Browse files Browse the repository at this point in the history
Same as using file://$DIRECTORY
  • Loading branch information
puffnfresh committed Apr 3, 2019
1 parent 59d5c28 commit b74a691
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
3 changes: 3 additions & 0 deletions hnix-store-binary/hnix-store-binary.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ cabal-version: >=1.10

library
exposed-modules: System.Nix.Store.Binary
, System.Nix.Store.Binary.Local

build-depends: base >=4.10 && <4.12
, binary
, bytestring
, directory
, filepath
, lzma
, mtl
, text
Expand Down
26 changes: 26 additions & 0 deletions hnix-store-binary/src/System/Nix/Store/Binary/Local.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{-|
Description : Interact with a local binary Nix store.
Maintainer : Brian McKenna <[email protected]>
-}
module System.Nix.Store.Binary.Local (
localBinaryStoreEffects
) where

import Control.Monad.Trans (MonadIO(..))
import System.Directory
import System.FilePath
import System.Nix.Store.Binary
import qualified Data.ByteString as BS
import qualified Data.Text as T

localBinaryStoreEffects
:: (MonadIO m)
=> FilePath
-> BinaryStoreEffects m
localBinaryStoreEffects cacheDir =
BinaryStoreEffects upsertFile'
where
upsertFile' pth d _ = liftIO $ do
let pth' = cacheDir </> T.unpack pth
createDirectoryIfMissing True $ takeDirectory pth'
BS.writeFile pth' d

0 comments on commit b74a691

Please sign in to comment.