Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zig build dependencies: name the hash function used in the manifest #14284

Closed
Tracked by #14265
andrewrk opened this issue Jan 13, 2023 · 6 comments
Closed
Tracked by #14265

zig build dependencies: name the hash function used in the manifest #14284

andrewrk opened this issue Jan 13, 2023 · 6 comments
Labels
breaking Implementing this issue could cause existing code to no longer compile or have different behavior. enhancement Solving this issue will likely involve adding new logic or components to the codebase. zig build system std.Build, the build runner, `zig build` subcommand, package management
Milestone

Comments

@andrewrk
Copy link
Member

andrewrk commented Jan 13, 2023

Extracted from #14265.

Currently the build.zig.ini file uses:

hash=c9b30cffc40999d2c078ff350cbcee642970a224fe123c756d0892f876cf1aae

This is a SHA-256 hex-encoded digest. This proposal is to change it to:

hash.digest=c9b30cffc40999d2c078ff350cbcee642970a224fe123c756d0892f876cf1aae
hash.function=sha256

Or perhaps:

hash=sha256=c9b30cffc40999d2c078ff350cbcee642970a224fe123c756d0892f876cf1aae

Idea being to leave room for an upgrade to a different hash function in the future.

The second form may be preferred in order to ease copy+pasting from an error message, and so that diffs of hashes are only one line each.

Another possible syntax would be to use _ instead of = which would allow hashes to be used as field names in #14290 without use of @"" syntax.

@andrewrk andrewrk added enhancement Solving this issue will likely involve adding new logic or components to the codebase. breaking Implementing this issue could cause existing code to no longer compile or have different behavior. zig build system std.Build, the build runner, `zig build` subcommand, package management labels Jan 13, 2023
@andrewrk andrewrk added this to the 0.11.0 milestone Jan 13, 2023
@andrewrk andrewrk mentioned this issue Jan 13, 2023
32 tasks
@deflock
Copy link

deflock commented Jan 13, 2023

Nix uses hash: sha256-<base64(hash)>, cannot be selected by double-clicking.

Does it make sense to support more than one hashing method? Earlier it was popular to have md5+sha1.
Looks like hash is going to be package's unique id and it may complicate resolving in some way 🤔

@nektro
Copy link
Contributor

nektro commented Jan 13, 2023

i also prefer the latter one line version

@motiejus
Copy link
Contributor

motiejus commented Jan 13, 2023

When we start phasing out sha256 far in the future, transitional period may be easier by using two hash functions simultaneously. Perhaps we should consider a format that can support multiple hashes for the same artifact.

Therefore, if we do this:

hash=sha256=c9b30cffc40999d2c078ff350cbcee642970a224fe123c756d0892f876cf1aae

Implies that there is only a single hash, or multiple fields in the same section are allowed.

hash_sha256, hash.sha256 or variants would resolve this.

Like others, I agree that having algorithm+hash on the same line makes sense: one cannot live without the other, and don't bloat the line too much.

@leroycep
Copy link
Contributor

There is multihash. It encodes the hash algorithm + the hash size in a binary format. That would make it more difficult for the user to tell which format it is from the file. Anyway, I think it's at least worth considering including the hash size along with the algorithm like multihash does.

@chr-1x
Copy link

chr-1x commented Jan 13, 2023

If using ZON, it'd be pretty neat to support multiple hashes like:

.hash = {
    .sha256 = "bfac1bf4e5ab32b7a2cc424bf35b2eade5b783757a90d3108a4173bb1684dbe9",
    .md5 = "965cc7027c64265a2e4bd602dfcc85b1",
},

In this case having only one hash function can simplify to the oneliner:

.hash = { .sha256 = "bfac1bf4e5ab32b7a2cc424bf35b2eade5b783757a90d3108a4173bb1684dbe9" },

@gcoakes
Copy link
Contributor

gcoakes commented Jan 14, 2023

There is multihash.

I implemented multihash already, if anyone wants to rip it for use here. https://git.sr.ht/~gcoakes/zig-multihash

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Implementing this issue could cause existing code to no longer compile or have different behavior. enhancement Solving this issue will likely involve adding new logic or components to the codebase. zig build system std.Build, the build runner, `zig build` subcommand, package management
Projects
Archived in project
Development

No branches or pull requests

7 participants