Skip to content

Commit 1c72f5c

Browse files
committed
Complete and cleanup builtins list
1 parent d551b89 commit 1c72f5c

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

src/Nix/Builtins.hs

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,18 +145,19 @@ builtinsList = sequence
145145
version <- toValue (5 :: Int)
146146
pure $ Builtin Normal ("langVersion", version)
147147

148-
, add0 Normal "nixPath" nixPath
149148
, add TopLevel "abort" throw_ -- for now
150149
, add2 Normal "add" add_
151150
, add2 Normal "addErrorContext" addErrorContext
152151
, add2 Normal "all" all_
153152
, add2 Normal "any" any_
153+
, add2 Normal "appendContext" appendContext
154154
, add Normal "attrNames" attrNames
155155
, add Normal "attrValues" attrValues
156156
, add TopLevel "baseNameOf" baseNameOf
157157
, add2 Normal "bitAnd" bitAnd
158158
, add2 Normal "bitOr" bitOr
159159
, add2 Normal "bitXor" bitXor
160+
, add0 Normal "builtins" builtinsBuiltin
160161
, add2 Normal "catAttrs" catAttrs
161162
, add2 Normal "compareVersions" compareVersions_
162163
, add Normal "concatLists" concatLists
@@ -235,6 +236,7 @@ builtinsList = sequence
235236
, add2 TopLevel "map" map_
236237
, add2 TopLevel "mapAttrs" mapAttrs_
237238
, add2 Normal "match" match_
239+
, add0 Normal "nixPath" nixPath
238240
, add2 Normal "mul" mul_
239241
, add0 Normal "null" (pure $ nvConstant NNull)
240242
, add Normal "parseDrvName" parseDrvName
@@ -244,6 +246,16 @@ builtinsList = sequence
244246
, add Normal "readDir" readDir_
245247
, add Normal "readFile" readFile_
246248
, add2 Normal "findFile" findFile_
249+
{-
250+
, add Normal "fetchGit" fetchGit
251+
, add Normal "fetchMercurial" fetchMercurial
252+
, add Normal "filterSource" filterSource
253+
, add Normal "fromTOML" fromTOML
254+
-}
255+
, add Normal "getContext" getContext
256+
{-
257+
, add Normal "path" path
258+
-}
247259
, add2 TopLevel "removeAttrs" removeAttrs
248260
, add3 Normal "replaceStrings" replaceStrings
249261
, add2 TopLevel "scopedImport" scopedImport
@@ -252,6 +264,9 @@ builtinsList = sequence
252264
, add2 Normal "split" split_
253265
, add Normal "splitVersion" splitVersion_
254266
, add0 Normal "storeDir" (pure $ nvStr $ principledMakeNixStringWithoutContext "/nix/store")
267+
{-
268+
, add Normal "storePath" storePath
269+
-}
255270
, add' Normal "stringLength" (arity1 $ Text.length . principledStringIgnoreContext)
256271
, add' Normal "sub" (arity2 ((-) @Integer))
257272
, add' Normal "substring" (substring @e @t @f @m)
@@ -266,12 +281,13 @@ builtinsList = sequence
266281
, add2 TopLevel "trace" trace_
267282
, add Normal "tryEval" tryEval
268283
, add Normal "typeOf" typeOf
284+
, add2 Normal "unsafeGetAttrPos" unsafeGetAttrPos
285+
, add Normal "unsafeDiscardStringContext" unsafeDiscardStringContext
286+
{-
287+
, add0 Normal "unsafeDiscardOutputDependency" unsafeDiscardOutputDependency
288+
-}
269289
, add Normal "valueSize" getRecursiveSize
270-
, add Normal "getContext" getContext
271-
, add2 Normal "appendContext" appendContext
272290

273-
, add2 Normal "unsafeGetAttrPos" unsafeGetAttrPos
274-
, add Normal "unsafeDiscardStringContext" unsafeDiscardStringContext
275291
]
276292
where
277293
wrap :: BuiltinType -> Text -> v -> Builtin v
@@ -766,6 +782,12 @@ bitXor
766782
bitXor x y = fromValue @Integer x
767783
>>= \a -> fromValue @Integer y >>= \b -> toValue (a `xor` b)
768784

785+
builtinsBuiltin
786+
:: forall e t f m
787+
. MonadNix e t f m
788+
=> m (NValue t f m)
789+
builtinsBuiltin = (throwError $ ErrorCall "HNix does not provide builtins.builtins at the moment. Using builtins directly should be preferred")
790+
769791
dirOf :: MonadNix e t f m => NValue t f m -> m (NValue t f m)
770792
dirOf x = demand x $ \case
771793
NVStr ns -> pure $ nvStr

0 commit comments

Comments
 (0)