hnix-store-core 0.6.0.0 → 0.6.1.0
raw patch · 4 files changed
+58/−26 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- ChangeLog.md +6/−0
- hnix-store-core.cabal +1/−1
- src/System/Nix/Internal/Nar/Streamer.hs +26/−25
- tests/NarFormat.hs +25/−0
ChangeLog.md view
@@ -1,5 +1,11 @@ # ChangeLog +## [0.6.1.0](https://github.com/haskell-nix/hnix-store/compare/core-0.6.0.0...core-0.6.1.0) 2023-01-02++* Fixed:++ * [(link)](https://github.com/haskell-nix/hnix-store/pull/201) [(link)](https://github.com/haskell-nix/hnix-store/pull/203) NAR serialization compatibility (symlinks, directory symlinks, UTF-8 handling)+ ## [0.6.0.0](https://github.com/haskell-nix/hnix-store/compare/core-0.5.0.0...core-0.6.0.0) 2022-06-06 * Breaking:
hnix-store-core.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.2 name: hnix-store-core-version: 0.6.0.0+version: 0.6.1.0 synopsis: Core effects for interacting with the Nix store. description: This package contains types and functions needed to describe
src/System/Nix/Internal/Nar/Streamer.hs view
@@ -1,6 +1,6 @@ -- | Stream out a NAR file from a regular file -{-# language ScopedTypeVariables #-}+{-# LANGUAGE ScopedTypeVariables #-} module System.Nix.Internal.Nar.Streamer ( NarSource@@ -16,8 +16,10 @@ import qualified Data.ByteString.Char8 as Bytes.Char8 import qualified Data.ByteString.Lazy as Bytes.Lazy import qualified Data.Serialize as Serial+import qualified Data.Text as T (pack)+import qualified Data.Text.Encoding as TE (encodeUtf8) import qualified System.Directory as Directory-import System.FilePath ( (</>) )+import System.FilePath ((</>)) import qualified System.Nix.Internal.Nar.Effects as Nar @@ -61,33 +63,32 @@ where go :: FilePath -> m () go path = do- isDir <- IO.liftIO $ Nar.narIsDir effs path isSymLink <- IO.liftIO $ Nar.narIsSymLink effs path- let isRegular = not $ isDir || isSymLink-- when isSymLink $ do+ if isSymLink then do target <- IO.liftIO $ Nar.narReadLink effs path yield $- strs ["type", "symlink", "target", Bytes.Char8.pack target]-- when isRegular $ do- isExec <- IO.liftIO $ isExecutable effs path- yield $ strs ["type", "regular"]- when (isExec == Executable) $ yield $ strs ["executable", ""]- fSize <- IO.liftIO $ Nar.narFileSize effs path- yield $ str "contents"- yield $ int fSize- yieldFile path fSize+ strs ["type", "symlink", "target", filePathToBS target]+ else do+ isDir <- IO.liftIO $ Nar.narIsDir effs path+ if isDir then do+ fs <- IO.liftIO (Nar.narListDir effs path)+ yield $ strs ["type", "directory"]+ forM_ (sort fs) $ \f -> do+ yield $ str "entry"+ parens $ do+ let fullName = path </> f+ yield $ strs ["name", filePathToBS f, "node"]+ parens $ go fullName+ else do+ isExec <- IO.liftIO $ isExecutable effs path+ yield $ strs ["type", "regular"]+ when (isExec == Executable) $ yield $ strs ["executable", ""]+ fSize <- IO.liftIO $ Nar.narFileSize effs path+ yield $ str "contents"+ yield $ int fSize+ yieldFile path fSize - when isDir $ do- fs <- IO.liftIO (Nar.narListDir effs path)- yield $ strs ["type", "directory"]- forM_ (sort fs) $ \f -> do- yield $ str "entry"- parens $ do- let fullName = path </> f- yield $ strs ["name", Bytes.Char8.pack f, "node"]- parens $ go fullName+ filePathToBS = TE.encodeUtf8 . T.pack parens act = do yield $ str "("
tests/NarFormat.hs view
@@ -115,6 +115,8 @@ it "matches directory" $ do encEqualsNixStore (Nar sampleDirectory) sampleDirectoryBaseline+ it "matches symlink to directory" $ do+ encEqualsNixStore (Nar sampleLinkToDirectory) sampleLinkToDirectoryBaseline unit_nixStoreRegular :: HU.Assertion@@ -452,6 +454,14 @@ ) ] +sampleLinkToDirectory :: FileSystemObject+sampleLinkToDirectory = Directory $ Map.fromList [+ (FilePathPart "foo", Directory $ Map.fromList [+ (FilePathPart "file", Regular Nar.NonExecutable 8 "foo text")+ ])+ , (FilePathPart "linkfoo" , SymLink "foo")+ ]+ -------------------------------------------------------------------------------- sampleDirWithManyFiles :: Int -> FileSystemObject sampleDirWithManyFiles nFiles =@@ -525,6 +535,21 @@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ase sizes (bytes) by env variable getBigFileSize :: IO Int64