!lymvtcwDJ7ZA9Npq:lix.systems

Lix Development

395 Members
(Technical) development of Lix, the package manager, a Nix implementation. Please be mindful of ongoing technical conversations in this channel.134 Servers

Load older messages


SenderMessageTime
14 Oct 2025
@emilazy:matrix.orgemily given it has to deal with >128-bit values and the formats are quirky, I am not sure there is a builtin that is significantly more scoped than builtins.convertHash that would make it possible to implement this efficiently and non-horribly given Nix's anaemic facilities for such processing 15:40:17
@emilazy:matrix.orgemilyI think the most you could reasonably scope it down is just omitting handling of the SRI stuff and making it do inter-conversion of strings between Base16/Base32/Base6415:41:27
@emilazy:matrix.orgemily and then handle the <alg>:<digest> and <alg>-<digest> formats in Nix code 15:41:44
@emilazy:matrix.orgemilybut even then it's not like you'll get something terribly general because e.g. you are still encoding quirks like Nix's Base32 endianness15:42:14
@emilazy:matrix.orgemily so I expect that in ~100% of cases people are just going to be using it for exactly what builtins.convertHash does 15:42:50
@emilazy:matrix.orgemily I suppose I can imagine someone trying to convert Base64 binary data to a hex dump or something… and if NUL bytes are going to be allowed in strings then it could be split into two separate encode/decode built-ins that go through binary blobs at a penalty of more allocations etc. 15:43:44
@emilazy:matrix.orgemilybut the general radix conversion thing seems like a total detour15:44:00
@raitobezarius:matrix.orgraitobezariusWhat about {from,to}{NixBase32,Base16,Base64} as primops?15:51:13
@raitobezarius:matrix.orgraitobezariusWhich seems to be that proposal ^15:51:21
@raitobezarius:matrix.orgraitobezariusIdeally, the primops should live under a namespace, e.g. conversions or something15:51:53
@emilazy:matrix.orgemilyIIRC Base32 is not unambiguously defined for some sizes of byte string.16:03:52
@emilazy:matrix.orgemilyso I believe these functions would not round-trip etc.16:04:03
@emilazy:matrix.orgemilyI am not sure if you would need to manually add/remove padding in Nix code to make the conversions go through16:04:38
@emilazy:matrix.orgemily it's at least avoided by convertHash taking specification of a hash which restricts the bit format to one of the "standard" ones 16:04:48
@emilazy:matrix.orgemily(it would also not be backportable to versions that use a NUL-terminated string representation and would be a permanent(?) divergence from Nix's choice to forbid NULs more thoroughly instead of course, but these may not be issues)16:05:51
@emilazy:matrix.orgemily I am also not entirely sure if there are any gremlins in the <algo>:<digest> format etc. which would be a pain to deal with in Nix 16:06:15
@emilazy:matrix.orgemily though it's probably tolerable if it's just in one lib function in Nixpkgs 16:06:22
@raitobezarius:matrix.orgraitobezarius Do you have a clear example of case where {from,to}NixBase32 would not roundtrip? 16:06:32
@raitobezarius:matrix.orgraitobezarius It's already known that Nix flavor of base32 is a bit special, but I cannot remember of seeing there was unambiguous cases. If anything, Nix always accepted $BASE32 + any char for a while (and probably still do). 16:07:06
@emilazy:matrix.orgemily frankly the hash formats are all very weird and I am not sure if it is really better to have their format details exposed to userspace rather than just treating them as opaque but interconvertible blogs 16:07:17
@raitobezarius:matrix.orgraitobezariusIt never honored any form of strict implementation of RFC464816:07:22
@emilazy:matrix.orgemilye.g. proliferation of Base32 use doesn't seem like a great thing16:07:32
@emilazy:matrix.orgemilyI believe there are cases where appending (or prepending?) a NUL byte will not change the result16:07:40
@emilazy:matrix.orgemilybecause of padding16:07:45
@emilazy:matrix.orgemilyand therefore decoding must fail to round-trip on one of them16:07:56
@emilazy:matrix.orgemilyI recall running into this when factoring out the Base32 functions16:08:03
@emilazy:matrix.orgemily Base32 lacks anything like Base64's = 16:08:46
@raitobezarius:matrix.orgraitobezariusThere are, but it only cause problem for strict implementations outside of CppNix/Lix16:09:48
@raitobezarius:matrix.orgraitobezarius(i.e. back when we dealt with nixbase32 in snix.)16:10:02
@emilazy:matrix.orgemily well, I mean that with to/from functions, Nixpkgs lib will have to implement the <algo>:<digest> and SRI logic 1:1 to match the implementations 16:10:28

Show newer messages


Back to Room ListRoom Version: 10