@@ -5,6 +5,7 @@ module NarFormat where
55
66import qualified Control.Concurrent as Concurrent
77import Control.Exception (try )
8+ import Data.Binary (Binary (.. ), decodeFile )
89import Data.Binary.Get (Get , getByteString ,
910 getInt64le ,
1011 getLazyByteString , runGet )
@@ -100,6 +101,10 @@ spec_narEncoding = do
100101 it " roundtrips directory" $ do
101102 roundTrip " sampleDirectory" (Nar sampleDirectory)
102103
104+ it " roundtrips case conflicts" $ do
105+ nar <- decodeFile " tests/fixtures/case-conflict.nar"
106+ roundTrip " caseConflict" nar
107+
103108 describe " matches-nix-store fixture" $ do
104109 it " matches regular" $ do
105110 encEqualsNixStore (Nar sampleRegular) sampleRegularBaseline
@@ -115,6 +120,7 @@ spec_narEncoding = do
115120
116121 it " matches directory" $ do
117122 encEqualsNixStore (Nar sampleDirectory) sampleDirectoryBaseline
123+
118124 it " matches symlink to directory" $ do
119125 encEqualsNixStore (Nar sampleLinkToDirectory) sampleLinkToDirectoryBaseline
120126
@@ -578,7 +584,7 @@ filePathPart :: BSC.ByteString -> Maybe FilePathPart
578584filePathPart p = if BSC. any (`elem` [' /' , ' \NUL ' ]) p then Nothing else Just $ FilePathPart p
579585
580586newtype Nar = Nar { narFile :: FileSystemObject }
581- deriving (Eq , Show )
587+ deriving (Eq , Show , Generic )
582588
583589-- | A FileSystemObject (FSO) is an anonymous entity that can be NAR archived
584590data FileSystemObject =
@@ -594,6 +600,9 @@ data FileSystemObject =
594600newtype FilePathPart = FilePathPart { unFilePathPart :: BSC. ByteString }
595601 deriving (Eq , Ord , Show )
596602
603+ instance Binary Nar where
604+ get = getNar
605+ put = putNar
597606
598607instance Arbitrary Nar where
599608 arbitrary = Nar <$> resize 10 arbitrary
0 commit comments