From 8b8ee53bc73769bb25d967ba259dabc9b23e2e6f Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 27 Nov 2012 13:29:55 +0100 Subject: Add builtin constants ‘langVersion’ and ‘nixVersion’ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The integer constant ‘langVersion’ denotes the current language version. It gets increased every time a language feature is added/changed/removed. It's currently 1. The string constant ‘nixVersion’ contains the current Nix version, e.g. "1.2pre2980_9de6bc5". --- src/libexpr/primops.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/libexpr') diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc index 509297003f6e..6876b2853add 100644 --- a/src/libexpr/primops.cc +++ b/src/libexpr/primops.cc @@ -1143,6 +1143,16 @@ void EvalState::createBaseEnv() mkString(v, settings.thisSystem.c_str()); addConstant("__currentSystem", v); + mkString(v, nixVersion.c_str()); + addConstant("__nixVersion", v); + + /* Language version. This should be increased every time a new + language feature gets added. It's not necessary to increase it + when primops get added, because you can just use `builtins ? + primOp' to check. */ + mkInt(v, 1); + addConstant("__langVersion", v); + // Miscellaneous addPrimOp("import", 1, prim_import); addPrimOp("isNull", 1, prim_isNull); -- cgit 1.4.1