summaryrefslogtreecommitdiffstats
path: root/lib/trivial.nix
diff options
context:
space:
mode:
Diffstat (limited to 'lib/trivial.nix')
-rw-r--r--lib/trivial.nix18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/trivial.nix b/lib/trivial.nix
index 936ad207c03d..5b7a1ee30f7a 100644
--- a/lib/trivial.nix
+++ b/lib/trivial.nix
@@ -200,6 +200,24 @@ in {
and = x: y: x && y;
/**
+ boolean “exclusive or”
+
+
+ # Inputs
+
+ `x`
+
+ : 1\. Function argument
+
+ `y`
+
+ : 2\. Function argument
+ */
+ # We explicitly invert the arguments purely as a type assertion.
+ # This is invariant under XOR, so it does not affect the result.
+ xor = x: y: (!x) != (!y);
+
+ /**
bitwise “not”
*/
bitNot = builtins.sub (-1);