about summary refs log tree commit diff
path: root/lib/trivial.nix
diff options
context:
space:
mode:
authormatthewcroughan <matt@croughan.sh>2021-11-14 23:14:09 +0000
committermatthewcroughan <matt@croughan.sh>2022-05-06 15:42:52 +0100
commit4d9801a78fff121703c4ea4dcef8b6746973165c (patch)
treee4a917a0f6e0404e54d2fadf464885ba440355f8 /lib/trivial.nix
parent70b3cbff57169566a22fb8df6a0fd3c3b9b21b6b (diff)
lib: add inPureEvalMode
This makes a value that is true if builtins does not contain the
currentSystem function, but false if it does.
Diffstat (limited to 'lib/trivial.nix')
-rw-r--r--lib/trivial.nix7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/trivial.nix b/lib/trivial.nix
index 18616a189c269..902c56a2d0aad 100644
--- a/lib/trivial.nix
+++ b/lib/trivial.nix
@@ -229,6 +229,13 @@ rec {
   */
   inNixShell = builtins.getEnv "IN_NIX_SHELL" != "";
 
+  /* Determine whether the function is being called from inside pure-eval mode
+     by seeing whether `builtins` contains `currentSystem`. If not, we must be in
+     pure-eval mode.
+
+     Type: inPureEvalMode :: bool
+  */
+  inPureEvalMode = ! builtins ? currentSystem;
 
   ## Integer operations