diff options
author | jade <lix@jade.fyi> | 2024-03-17 12:13:21 -0600 |
---|---|---|
committer | Gerrit Code Review <gerrit@lix> | 2024-03-17 12:13:21 -0600 |
commit | 706cee5c493b39e25bdb0add55d2e1771dc31696 (patch) | |
tree | eb4de95498a852a49e3ca218ada60eb04d6b87b3 | |
parent | 32d6e5806973c95050c26845ae4de3f7861a8678 (diff) | |
parent | 886a418d23c6d4412c5d0d5c6280bb7a818def2b (diff) |
Merge "builtins.nixVersion: return fixed fake version" into main
-rw-r--r-- | src/libexpr/primops.cc | 21 | ||||
-rw-r--r-- | tests/unit/libexpr/primops.cc | 2 |
2 files changed, 7 insertions, 16 deletions
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc index 83eccb818..a5b539202 100644 --- a/src/libexpr/primops.cc +++ b/src/libexpr/primops.cc @@ -4299,25 +4299,16 @@ void EvalState::createBaseEnv() .impureOnly = true, }); - v.mkString(nixVersion); + v.mkString("2.18.3-lix"); addConstant("__nixVersion", v, { .type = nString, .doc = R"( - The version of Nix. + Legacy version of Nix. Always returns "2.18.3-lix" on Lix. - For example, where the command line returns the current Nix version, - - ```shell-session - $ nix --version - nix (Nix) 2.16.0 - ``` - - the Nix language evaluator returns the same value: - - ```nix-repl - nix-repl> builtins.nixVersion - "2.16.0" - ``` + To determine if features exist, Nix scripts should instead use direct + means of feature detection, such as checking for existence of + builtins they want to use. Doing so allows for much better compatibility + across implementations. )", }); diff --git a/tests/unit/libexpr/primops.cc b/tests/unit/libexpr/primops.cc index 71e838b32..bd174a6c0 100644 --- a/tests/unit/libexpr/primops.cc +++ b/tests/unit/libexpr/primops.cc @@ -611,7 +611,7 @@ namespace nix { TEST_F(PrimOpTest, nixVersion) { auto v = eval("builtins.nixVersion"); - ASSERT_THAT(v, IsStringEq(nixVersion)); + ASSERT_THAT(v, IsStringEq("2.18.3-lix")); } TEST_F(PrimOpTest, currentSystem) { |