Merge pull request #263 from gdevanla/master

add TopLevel placeHolder to builtins module
This commit is contained in:
John Wiegley 2018-05-02 14:19:10 -07:00 committed by GitHub
commit 431006f524
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View file

@ -167,6 +167,7 @@ builtinsList = sequence [
, add Normal "parseDrvName" parseDrvName
, add2 Normal "partition" partition_
, add Normal "pathExists" pathExists_
, add TopLevel "placeholder" placeHolder
, add Normal "readDir" readDir_
, add Normal "readFile" readFile_
, add2 TopLevel "removeAttrs" removeAttrs
@ -766,6 +767,11 @@ hashString algo s = Prim $ do
++ "expected \"md5\", \"sha1\", \"sha256\", or \"sha512\", got " ++ show algo
pure $ decodeUtf8 $ Base16.encode $ hash $ encodeUtf8 s
placeHolder :: MonadNix e m => m (NValue m) -> m (NValue m)
placeHolder = fromValue @Text >=> \_ -> hash $ Text.pack "fdasdfas"
where
hash x = (toBuiltin "") . hashString (Text.pack "sha256") $ x
absolutePathFromValue :: MonadNix e m => NValue m -> m FilePath
absolutePathFromValue = \case
NVStr pathText _ -> do

View file

@ -144,6 +144,9 @@ let
in [ (fix toFixFold) (fix toFix) ]
|]
case_placeholder =
constantEqualText "\"ed0d01fb5aba979d0beeffb3c2bdffb5cfda021955b776cce0a47058708b3157\"" "builtins.placeholder \"out\""
-----------------------
tests :: TestTree