-
Notifications
You must be signed in to change notification settings - Fork 23
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
nix-store path calculation #217
Comments
I don't see anything obvious immediately but it's been a while since I read the paper. You might want to check |
Hi! Have you managed to figure it out? It's pretty cool that you can use our code as a reference even as a non-Haskeller! Btw, what's your motivation for implementing this? |
Hi, no worries :)
Unfortunately, I wasn't able to make any progress. I bet that this is quite a subtle difference which makes it even harder to spot in the code.
well, to some degree modulo my haskell skills 😆 I plan to ran your code against the same package and check both final and intermediate results, but not knowing haskell doesn't help my motivation these days.
So, I want to create a build tool for scala that will piggy back on nix as much as possible.
I hope it makes sense 😅 |
CC @flokli |
@ghostbuster91 Two other things:
|
Re. content-addressing - yeah I heard about it and it seems that it should work. Not sure yet how much lack of hydra will be of a problem. I will need to check this. However, since I got already quite far I wanted to finish implementing that approach. I didn't find many resources on that topic hence I figured out that I will write a blogpost documenting how this process works under the hood. So this kind of become a goal on its own :) Re. |
@ghostbuster91 |
As I got cc'ed - In case reading another implementation might help - during the development of Tvix we reverse-engineered the output path calculation and produced some general-purpose (rust) code in Consumers of this code are a bunch of testcases, as well as Maybe some of that code helps you to understand where things happen differently? |
@Ericson2314 thanks, I didn't know about this. I will check it out 👍
It definitively will. I grew up on imperative code so reading rust should be easier. Thanks for the links 🙇♂️ |
Hi,
First, a little bit of context. I am trying to programatically generate nix derivation using scala. It turned out that I need to calculate nix-store path in order to put the drv file into the nix-store (which is a requirement for realizing it).
Because of that I started to implement minimialistic version of hnix-store in scala, so that I can calculate the nix-store output path. I tried reading The Purely Functional Software
Deployment Model and the code in this repository (though I don't know much haskell), however it was enough for me to get started. Then I also found https://web.archive.org/web/20221001050043/https://comono.id/posts/2020-03-20-how-nix-instantiation-works/ which was an invaluable help.
I am at the point where I can calculate nix-store path correctly for some real derivations like
"/nix/store/dsn6vl7x1hbn1akgpxync19gpx2dzy8w-bootstrap-tools"
or more complex/nix/store/32lr8w57frc1ij5wzc3hb9ks8vzs2ms1-libffi-3.4.4.drv
.However, for some reason I cannot calculate correctly nix-store path for
"/nix/store/h8z4rypl78kwais0yim76czxjnd55dsm-python3-minimal-3.10.12"
There must be something different about this package/its inputDrvs but I fail to spot anything.
I wonder if you know any better resources about the algorithm used to calculate nix-store paths.
I will list steps that I do, in the hope that maybe someone will be able to spot a mistake:
(fixed hash derivation are left out for brevity)
sha256("output:out:sha256:${sha256(d)}:/nix/store:${d.env("name")}")
descriptor hashes are calculated as follows:
sha256("fixed:out:${d.hashAlgo}:${d.hash}:${d.path.get}")
sha256(derivation)
If anything I think that I might be handling multiple outputs incorrectly.
If there is a derivation
A
that defines several outputs:and then we depend on such derivation in
B
:I don't change my logic for calculating
B
descriptor in terms ofA
and I do it the same way as if there was only a single outputout
both defined inB
and used inA
.Thanks in advance 🙇♂️
The text was updated successfully, but these errors were encountered: