add builtins.hashfile

This commit is contained in:
soulomoon 2022-01-05 14:56:18 +00:00 committed by Anton Latukha
parent 4f94e33de0
commit 8e64e98fd8
2 changed files with 15 additions and 2 deletions

View File

@ -1424,6 +1424,18 @@ hashStringNix nsAlgo ns =
mkHash s = hash $ encodeUtf8 s
-- | hashFileNix
-- use hashStringNix to hash file content
hashFileNix
:: forall e t f m . MonadNix e t f m => NixString -> Path -> Prim m NixString
hashFileNix nsAlgo nvfilepath = Prim $ hash =<< fileContent
where
hash = outPrim . hashStringNix nsAlgo
outPrim (Prim x) = x
fileContent :: m NixString
fileContent = mkNixStringWithoutContext <$> Nix.Render.readFile nvfilepath
placeHolderNix :: forall t f m e . MonadNix e t f m => NValue t f m -> m (NValue t f m)
placeHolderNix p =
do
@ -1853,6 +1865,7 @@ builtinsList =
, add2 Normal "hasAttr" hasAttrNix
, add Normal "hasContext" hasContextNix
, add' Normal "hashString" (hashStringNix @e @t @f @m)
, add' Normal "hashFile" hashFileNix
, add Normal "head" headNix
, add2 Normal "intersectAttrs" intersectAttrsNix
, add Normal "isAttrs" isAttrsNix

View File

@ -56,8 +56,8 @@ groupBy key = Map.fromListWith (<>) . fmap (key &&& pure)
-- previously passed.
newFailingTests :: Set String
newFailingTests = Set.fromList
[ "eval-okay-hash"
, "eval-okay-hashfile"
[
"eval-okay-hash"
, "eval-okay-path" -- #128
, "eval-okay-fromTOML"
, "eval-okay-ind-string" -- #1000 #610