Loading lib/default.nix +1 −1 Original line number Diff line number Diff line Loading @@ -69,7 +69,7 @@ let hasAttr head isAttrs isBool isInt isList isPath isString length lessThan listToAttrs pathExists readFile replaceStrings seq stringLength sub substring tail trace; inherit (self.trivial) id const pipe concat or and bitAnd bitOr bitXor inherit (self.trivial) id const pipe concat or and xor bitAnd bitOr bitXor bitNot boolToString mergeAttrs flip mapNullable inNixShell isFloat min max importJSON importTOML warn warnIf warnIfNot throwIf throwIfNot checkListOfEnum info showWarnings nixpkgsVersion version isInOldestRelease Loading lib/tests/misc.nix +16 −0 Original line number Diff line number Diff line Loading @@ -106,6 +106,7 @@ let types updateManyAttrsByPath versions xor ; testingThrow = expr: { Loading Loading @@ -214,6 +215,21 @@ runTests { expected = false; }; testXor = { expr = [ (xor true false) (xor true true) (xor false false) (xor false true) ]; expected = [ true false false true ]; }; testFix = { expr = fix (x: {a = if x ? a then "a" else "b";}); expected = {a = "a";}; Loading lib/trivial.nix +18 −0 Original line number Diff line number Diff line Loading @@ -199,6 +199,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” */ Loading nixos/modules/config/users-groups.nix +0 −1 Original line number Diff line number Diff line Loading @@ -871,7 +871,6 @@ in { } { assertion = let xor = a: b: a && !b || b && !a; isEffectivelySystemUser = user.isSystemUser || (user.uid != null && user.uid < 1000); in xor isEffectivelySystemUser user.isNormalUser; message = '' Loading nixos/modules/services/networking/kea.nix +0 −1 Original line number Diff line number Diff line Loading @@ -9,7 +9,6 @@ with lib; let cfg = config.services.kea; xor = x: y: (!x && y) || (x && !y); format = pkgs.formats.json {}; chooseNotNull = x: y: if x != null then x else y; Loading Loading
lib/default.nix +1 −1 Original line number Diff line number Diff line Loading @@ -69,7 +69,7 @@ let hasAttr head isAttrs isBool isInt isList isPath isString length lessThan listToAttrs pathExists readFile replaceStrings seq stringLength sub substring tail trace; inherit (self.trivial) id const pipe concat or and bitAnd bitOr bitXor inherit (self.trivial) id const pipe concat or and xor bitAnd bitOr bitXor bitNot boolToString mergeAttrs flip mapNullable inNixShell isFloat min max importJSON importTOML warn warnIf warnIfNot throwIf throwIfNot checkListOfEnum info showWarnings nixpkgsVersion version isInOldestRelease Loading
lib/tests/misc.nix +16 −0 Original line number Diff line number Diff line Loading @@ -106,6 +106,7 @@ let types updateManyAttrsByPath versions xor ; testingThrow = expr: { Loading Loading @@ -214,6 +215,21 @@ runTests { expected = false; }; testXor = { expr = [ (xor true false) (xor true true) (xor false false) (xor false true) ]; expected = [ true false false true ]; }; testFix = { expr = fix (x: {a = if x ? a then "a" else "b";}); expected = {a = "a";}; Loading
lib/trivial.nix +18 −0 Original line number Diff line number Diff line Loading @@ -199,6 +199,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” */ Loading
nixos/modules/config/users-groups.nix +0 −1 Original line number Diff line number Diff line Loading @@ -871,7 +871,6 @@ in { } { assertion = let xor = a: b: a && !b || b && !a; isEffectivelySystemUser = user.isSystemUser || (user.uid != null && user.uid < 1000); in xor isEffectivelySystemUser user.isNormalUser; message = '' Loading
nixos/modules/services/networking/kea.nix +0 −1 Original line number Diff line number Diff line Loading @@ -9,7 +9,6 @@ with lib; let cfg = config.services.kea; xor = x: y: (!x && y) || (x && !y); format = pkgs.formats.json {}; chooseNotNull = x: y: if x != null then x else y; Loading