blob: 62bfd145c0a9914c6f2b8e204831f4a1470c3f64 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
//! This module implements the builtins exposed in the Nix language.
//!
//! See //tvix/eval/docs/builtins.md for a some context on the
//! available builtins in Nix.
use std::collections::HashMap;
use crate::value::{Builtin, Value};
macro_rules! builtin {
( $map:ident, $name:literal, $arity:literal, $body:expr ) => {
$map.insert($name, Value::Builtin(Builtin::new($name, $arity, $body)));
};
}
/// Set of Nix builtins that are globally available.
pub fn global_builtins() -> HashMap<&'static str, Value> {
let mut globals = HashMap::new();
builtin!(globals, "toString", 1, |args| {
// TODO: toString is actually not the same as Display
Ok(Value::String(format!("{}", args[0]).into()))
});
globals
}
|