1
1
Fork 1
mirror of https://github.com/oddlama/nixos-extra-modules.git synced 2025-10-10 22:00:39 +02:00

chore: remove builtin reexport

This commit is contained in:
Patrick 2025-04-15 11:35:45 +02:00
parent fda0b800e1
commit 5cc4cb34fb
No known key found for this signature in database
GPG key ID: 451F95EFB8BECD0F

View file

@ -463,24 +463,16 @@ let
inherit (import ./shift.nix) left arithmeticRight logicalRight; inherit (import ./shift.nix) left arithmeticRight logicalRight;
leftOrArithRight = a: if a > 0 then left a else arithmeticRight (-a); leftOrArithRight = a: if a > 0 then left a else arithmeticRight (-a);
arithRightOrLeft = a: if a > 0 then arithmeticRight a else left (-a); arithRightOrLeft = a: if a > 0 then arithmeticRight a else left (-a);
and = builtins.bitAnd;
or = builtins.bitOr; not = builtins.bitXor (-1);
xor = builtins.bitXor; mask = n: builtins.bitAnd (left n 1 - 1);
not = xor (-1);
mask = n: and (left n 1 - 1);
in in
{ {
inherit inherit
left left
arithmeticRight arithmeticRight
logicalRight logicalRight
and
or
xor
not not
mask mask
leftOrArithRight leftOrArithRight
@ -649,7 +641,7 @@ let
}; };
fromDecimalDigits = builtins.foldl' (a: c: a * 10 + c) 0; fromDecimalDigits = builtins.foldl' (a: c: a * 10 + c) 0;
fromHexadecimalDigits = builtins.foldl' (a: bit.or (bit.left 4 a)) 0; fromHexadecimalDigits = builtins.foldl' (a: builtins.bitOr (bit.left 4 a)) 0;
# disallow leading zeros # disallow leading zeros
decimal = bind (digit decimalDigits) ( decimal = bind (digit decimalDigits) (
@ -671,7 +663,7 @@ let
octet' = then_ dot octet; octet' = then_ dot octet;
fromOctets = a: b: c: d: { fromOctets = a: b: c: d: {
ipv4 = bit.or (bit.left 8 (bit.or (bit.left 8 (bit.or (bit.left 8 a) b)) c)) d; ipv4 = builtins.bitOr (bit.left 8 (builtins.bitOr (bit.left 8 (builtins.bitOr (bit.left 8 a) b)) c)) d;
}; };
in in
liftA4 fromOctets octet octet' octet' octet'; liftA4 fromOctets octet octet' octet' octet';
@ -701,10 +693,10 @@ let
in in
pure { pure {
ipv6 = { ipv6 = {
a = bit.or (bit.left 16 a) b; a = builtins.bitOr (bit.left 16 a) b;
b = bit.or (bit.left 16 c) d; b = builtins.bitOr (bit.left 16 c) d;
c = bit.or (bit.left 16 e) f; c = builtins.bitOr (bit.left 16 e) f;
d = bit.or (bit.left 16 g) h; d = builtins.bitOr (bit.left 16 g) h;
}; };
}; };
@ -767,7 +759,7 @@ let
octet' = then_ colon octet; octet' = then_ colon octet;
fromOctets = a: b: c: d: e: f: { fromOctets = a: b: c: d: e: f: {
mac = bit.or (bit.left 8 (bit.or (bit.left 8 (bit.or (bit.left 8 (bit.or (bit.left 8 (bit.or (bit.left 8 a) b)) c)) d)) e)) f; mac = builtins.bitOr (bit.left 8 (builtins.bitOr (bit.left 8 (builtins.bitOr (bit.left 8 (builtins.bitOr (bit.left 8 (builtins.bitOr (bit.left 8 a) b)) c)) d)) e)) f;
}; };
in in
liftA6 fromOctets octet octet' octet' octet' octet' octet'; liftA6 fromOctets octet octet' octet' octet' octet' octet';
@ -963,22 +955,22 @@ let
if a ? ipv6 then if a ? ipv6 then
{ {
ipv6 = { ipv6 = {
a = bit.or a.ipv6.a b.ipv6.a; a = builtins.bitOr a.ipv6.a b.ipv6.a;
b = bit.or a.ipv6.b b.ipv6.b; b = builtins.bitOr a.ipv6.b b.ipv6.b;
c = bit.or a.ipv6.c b.ipv6.c; c = builtins.bitOr a.ipv6.c b.ipv6.c;
d = bit.or a.ipv6.d b.ipv6.d; d = builtins.bitOr a.ipv6.d b.ipv6.d;
}; };
} }
else if a ? ipv4 then else if a ? ipv4 then
{ {
ipv4 = bit.or a.ipv4 b.ipv4; ipv4 = builtins.bitOr a.ipv4 b.ipv4;
} }
else if a ? mac then else if a ? mac then
{ {
mac = bit.or a.mac b.mac; mac = builtins.bitOr a.mac b.mac;
} }
else else
bit.or a b; builtins.bitOr a b;
# and :: (ip | mac | integer) -> (ip | mac | integer) -> (ip | mac | integer) # and :: (ip | mac | integer) -> (ip | mac | integer) -> (ip | mac | integer)
and = and =
@ -989,22 +981,22 @@ let
if a ? ipv6 then if a ? ipv6 then
{ {
ipv6 = { ipv6 = {
a = bit.and a.ipv6.a b.ipv6.a; a = builtins.bitAnd a.ipv6.a b.ipv6.a;
b = bit.and a.ipv6.b b.ipv6.b; b = builtins.bitAnd a.ipv6.b b.ipv6.b;
c = bit.and a.ipv6.c b.ipv6.c; c = builtins.bitAnd a.ipv6.c b.ipv6.c;
d = bit.and a.ipv6.d b.ipv6.d; d = builtins.bitAnd a.ipv6.d b.ipv6.d;
}; };
} }
else if a ? ipv4 then else if a ? ipv4 then
{ {
ipv4 = bit.and a.ipv4 b.ipv4; ipv4 = builtins.bitAnd a.ipv4 b.ipv4;
} }
else if a ? mac then else if a ? mac then
{ {
mac = bit.and a.mac b.mac; mac = builtins.bitAnd a.mac b.mac;
} }
else else
bit.and a b; builtins.bitAnd a b;
# not :: (ip | mac | integer) -> (ip | mac | integer) # not :: (ip | mac | integer) -> (ip | mac | integer)
not = not =
@ -1082,7 +1074,7 @@ let
result.a == 0 && result.b == 0 && bit.arithmeticRight 31 result.c == 0 result.a == 0 && result.b == 0 && bit.arithmeticRight 31 result.c == 0
|| result.a == max32 && result.b == max32 && bit.arithmeticRight 31 result.c == 1 || result.a == max32 && result.b == max32 && bit.arithmeticRight 31 result.c == 1
then then
bit.or (bit.left 32 result.c) result.d builtins.bitOr (bit.left 32 result.c) result.d
else else
{ {
ipv6 = result; ipv6 = result;
@ -1103,7 +1095,7 @@ let
_6 = bit.mask 32 (bit.arithRightOrLeft (i - 64) x); _6 = bit.mask 32 (bit.arithRightOrLeft (i - 64) x);
_7 = bit.mask 32 (bit.arithRightOrLeft (i - 96) x); _7 = bit.mask 32 (bit.arithRightOrLeft (i - 96) x);
}; };
ors = builtins.foldl' bit.or 0; ors = builtins.foldl' builtins.bitOr 0;
in in
i: x: i: x:
if x ? ipv6 then if x ? ipv6 then
@ -1212,7 +1204,7 @@ let
else if target ? mac then else if target ? mac then
if value ? ipv6 then if value ? ipv6 then
{ {
mac = bit.or (bit.left 32 (bit.mask 16 value.ipv6.c)) value.ipv6.d; mac = builtins.bitOr (bit.left 32 (bit.mask 16 value.ipv6.c)) value.ipv6.d;
} }
else if value ? ipv4 then else if value ? ipv4 then
{ {
@ -1225,7 +1217,7 @@ let
mac = bit.mask 48 value; mac = bit.mask 48 value;
} }
else if value ? ipv6 then else if value ? ipv6 then
builtins.foldl' bit.or 0 [ builtins.foldl' builtins.bitOr 0 [
(bit.left 96 value.ipv6.a) (bit.left 96 value.ipv6.a)
(bit.left 64 value.ipv6.b) (bit.left 64 value.ipv6.b)
(bit.left 32 value.ipv6.c) (bit.left 32 value.ipv6.c)