merge/implement CppNix 2.19+ feature: builtins.convertHash #602
Labels
No labels
Area/build-packaging
Area/cli
Area/evaluator
Area/fetching
Area/flakes
Area/language
Area/profiles
Area/protocol
Area/releng
Area/remote-builds
Area/repl
Area/store
bug
crash 💥
Cross Compilation
devx
docs
Downstream Dependents
E/easy
E/hard
E/help wanted
E/reproducible
E/requires rearchitecture
imported
Needs Langver
OS/Linux
OS/macOS
performance
regression
release-blocker
RFD
stability
Status
blocked
Status
invalid
Status
postponed
Status
wontfix
testing
testing/flakey
ux
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: lix-project/lix#602
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Is your feature request related to a problem? Please describe.
I wanted to take a shot at implementing a Rust build system on crate-level that doesn't require IFD when provided with a Cargo.lock (which should be possible since the entire spec can be generated from the lockfile, that's what its purpose is).
However, not being able to convert the native sha256 to SRI hashes is a showstopper.
The feature exists in CppNix 2.19+ however.
Describe the solution you'd like
Merging that specific feature, kinda like:
Though I haven't checked if there are merge conflicts, and due to ongoing Lix development there may be other reasons to not just merge it of course.
Describe alternatives you've considered
This issue was mentioned on Gerrit on the following CLs:
Hi there, what about generalizing the built-in to allow arbitrary baseXYZ transformations? This would be useful for much more than
builtins.convertHash
which would be a specialization of that general builtin.cc @tom-hubrecht
As a potential user of said code; yes, but also "arbitrary baseXYZ transformations" may be a headache to provide since I know at least three different ways to do base32 alone.
Since CppNix already had the hash conversion I figured porting that made the most sense (since it provides compatibility too).
IMHO any additional APIs beyond that one would probably be better expressed in a design document featuring current annoyances in general so that some general patterns can be found.
Remember how I mentioned that octal numbers are basically just not a thing in Nix, so providing something as simple as a radix based conversion (with an optional mapping table) would make implementing a custom baseXYZ implementation a lot easier (exploding the string, using the
x:xs
pattern using the head and tail builtins and recursion, and shoving the x into the radix conversion function) and it would solve two issues at once.Like, have you ever tried to properly parse/format an IPv6 address in Nix?
Half my code in that regard makes strict assumptions about format and prefix length just because anything else would be awful to implement (currently), and parsing and formatting hex numbers is the minimum required to even start doing that and that one is hidden within nixpkgs' lib if memory serves (then again I'd prefer being able to treat an IPv6 address as a single 128 bit number for "easy math" reasons).
Same with a lot of other formatting things like padding (space or zero) for whatever reason, etc.
I think there should be a larger collection of annoyances (similar to the Wiki's Nix lang v2 page) so that they can be
TL;DR: I think generic baseXYZ conversions might be hard to implement (for Layer 8 reasons) and would solve a specific subset of problems potentially leading to more feature creep than a more generic approach.
I agree with you regarding base32 alone (I worked on the base32 implementation in Tvix and I saw terrible things.).
Hahahaha… :'(
What I gather from here is that you are for an even more generic way to generate baseXYZ conversions, e.g. radix based conversions, I think we are in agreement. Nonetheless, I believe this will be slower, right? Are you fine with that?
You are totally right, though we can have compatibility just by shipping a compat library in Nix code and this makes it easier for us to do things. We can also maybe invest in technology to hide certain builtins to prevent folks to depend on them and only have the libcompat Nix code access them. This is more work but this is well invested efforts rather than copying blindly CppNix who are effectively piling features without any reasoning on the global level (even though some of their developers try hard to keep things clean).
Would you be willing to drive this work? On our side, we can help on the design, review, etc. getting this to the finish line.