-
Notifications
You must be signed in to change notification settings - Fork 24
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
Improve digests generation and parsing #64
Conversation
@sorki rebased and augmented to fix recent additions. See "Fix parsing of cas path adresses" in particular. All references to hashType were removed. |
But it breaks some of hnix, as now SomeNamedDigest also has to be a Valid digest. |
Breakage fixed ! (I think, I did not manage to test :-/) |
Of course, haskell-nix/hnix#554 depends on this :-) |
<?> "Invalid Base32 part" | ||
digest <- parseDigest | ||
_ <- "fixed:" | ||
narHashMode <- (pure Recursive <$> "r:") <|> (pure RegularFile <$> "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not too sure here. Maybe it's really "true" and "false" ? In mkFixedOutputDerivation we also have a name after fixed:, as in fixed:out:...
How can I properly test this ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, in my repo I have a similar fix pending:
narHashMode <- Data.Attoparsec.ByteString.Char8.option RegularFile (pure Recursive <$> "r:")
but I've stopped at the digest
since it required changes from this PR.
For testing this I'll draft hnix-store-db
PR shortly.
_ <- "text:sha256:" | ||
digest <- decodeBase32 @'SHA256 <$> parseHash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also had this one simplified:
_ <- "text:sha256:" | |
digest <- decodeBase32 @'SHA256 <$> parseHash | |
_ <- "text:" | |
digest <- parseTypedHash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kept this one on purpose to fail on "text:xxx" where xxx is not sha256, which is the only allowed value.
We could however decide to be permissive here. Not sure which is best.
Force named hashes to be valid. After all, what would be the point of naming an invalid hash ? This avoids propagating manually the ValidAlgo requirement everywhere.
Superseded by #73. |
Reference: Main cause: haskell-hvr/cryptohash-sha512#7 The whole `cryptohash-*` package family is abandoned, there is no signs of maintainer activity there, so it stopped following Haskell ecosystem & `base` releases. Knowing the human history & situation around it - it would not be reviwed, which gives experience to not hardcode on the (specifically when emotional) dependency. Experience I drawn from this story is to keep things simplier when possible & have more flexible systems as a result code. It was "a bit too much" for what hashing is, for the code to have 2 hashing type systems (external & internal) & reinventment of `HashAlgorithm` type duplicate. The whole code was really rigid with a lot of type applicating the data kinds, those are dependent type features & should be used cautiously, since interface became rigid to changes, so afterwards it is easier to dismantle and recreate the subsystem then to evolve it. Previous hashing history: #156 #142 #93 #92 #90 #83 #64 #38 #32 #31 #28 #27 #25 #18 #14
Reference: Main cause: haskell-hvr/cryptohash-sha512#7 The whole `cryptohash-*` package family is abandoned, there is no signs of maintainer activity there, so it stopped following Haskell ecosystem & `base` releases. Knowing the human history & situation around it - it would not be reviwed, which gives experience to not hardcode on the (specifically when emotional) dependency. Experience I drawn from this story is to keep things simplier when possible & have more flexible systems as a result code. It was "a bit too much" for what hashing is, for the code to have 2 hashing type systems (external & internal) & reinventment of `HashAlgorithm` type duplicate. The whole code was really rigid with a lot of type applicating the data kinds, those are dependent type features & should be used cautiously, since interface became rigid to changes, so afterwards it is easier & effective to dismantle and recreate the subsystem then to evolve it. Previous hashing history: #156 #142 #93 #92 #90 #83 #64 #38 #32 #31 #28 #27 #25 #18 #14
Reference: Main cause: haskell-hvr/cryptohash-sha512#7 The whole `cryptohash-*` package family is abandoned, there is no signs of maintainer activity there, so it stopped following Haskell ecosystem & `base` releases. Knowing the human history & situation around it - it would not be reviwed, which gives experience to not hardcode on the (specifically when emotional) dependency. Experience I drawn from this story is to keep things simplier when possible & have more flexible systems as a result code. It was "a bit too much" for what hashing is, for the code to have 2 hashing type systems (external & internal) & reinventment of `HashAlgorithm` type duplicate. The whole code was really rigid with a lot of type applicating the data kinds, those are dependent type features & should be used cautiously, since interface became rigid to changes, so afterwards it is easier & effective to dismantle and recreate the subsystem then to evolve it. Previous hashing history: #156 #142 #93 #92 #90 #83 #64 #38 #32 #31 #28 #27 #25 #18 #14
Reference: Main cause: haskell-hvr/cryptohash-sha512#7 The whole `cryptohash-*` package family is abandoned, there is no signs of maintainer activity there, so it stopped following Haskell ecosystem & `base` releases. Knowing the human history & situation around it - it would not be reviwed, which gives experience to not hardcode on the (specifically when emotional) dependency. Experience I drawn from this story is to keep things simplier when possible & have more flexible systems as a result code. It was "a bit too much" for what hashing is, for the code to have 2 hashing type systems (external & internal) & reinventment of `HashAlgorithm` type duplicate. The whole code was really rigid with a lot of type applicating the data kinds, those are dependent type features & should be used cautiously, since interface became rigid to changes, so afterwards it is easier & effective to dismantle and recreate the subsystem then to evolve it. Previous hashing history: #156 #142 #93 #92 #90 #83 #64 #38 #32 #31 #28 #27 #25 #18 #14
Reference: Main cause: haskell-hvr/cryptohash-sha512#7 The whole `cryptohash-*` package family is abandoned, there is no signs of maintainer activity there, so it stopped following Haskell ecosystem & `base` releases. Knowing the human history & situation around it - it would not be reviwed, which gives experience to not hardcode on the (specifically when emotional) dependency. Experience I drawn from this story is to keep things simplier when possible & have more flexible systems as a result code. It was "a bit too much" for what hashing is, for the code to have 2 hashing type systems (external & internal) & reinventment of `HashAlgorithm` type duplicate. The whole code was really rigid with a lot of type applicating the data kinds, those are dependent type features & should be used cautiously, since interface became rigid to changes, so afterwards it is easier & effective to dismantle and recreate the subsystem then to evolve it. Previous hashing history: #156 #142 #93 #92 #90 #83 #64 #38 #32 #31 #28 #27 #25 #18 #14
This pr is based on top of #59 and fixes the only two isuues I encountered while writing prim_derivationStrict (place here the pr number in hnix when created).
Only the last two commits are relevant here.
0099f6d has a proper
Text -> SomeNamedDigest
function. Thechnically base64 hashes are not handled, but I did not enouter them in my tests (builing thehello
package)488fe78 fixes some quirks in hashes computations discovered by patiently comparing hnix and nix-instantiate outputs (I learned even more about dwarffs and gdb in the process :-))