about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2023-08-14T20·05+0200
committerflokli <flokli@flokli.de>2023-08-20T22·08+0000
commit9bb3f74062eaf4c9e1d109e9a91a191c907bc1dc (patch)
treea4ccecd4eff67cdc5a1f9504d5d8e15aab95ddf3
parent366e11b48a8e43b5075592f44f9923f07d13617a (diff)
docs(tvix/docs): add document about drvPath differences r/6510
This question popped up every once in a while. While already explained
quite well at
https://inbox.tvl.su/depot/20230316120039.j4fkp3puzrtbjcpi@tp/T/#t,
it's not easily accessible.

Lift it from there into tvix/docs for better visibility.

Change-Id: I5f2d4aff31ab4adc421e06a7d36c871f45e09100
Reviewed-on: https://cl.tvl.fyi/c/depot/+/9080
Autosubmit: flokli <flokli@flokli.de>
Reviewed-by: raitobezarius <tvl@lahfa.xyz>
Tested-by: BuildkiteCI
-rw-r--r--tvix/docs/differences-drv-paths.md46
1 files changed, 46 insertions, 0 deletions
diff --git a/tvix/docs/differences-drv-paths.md b/tvix/docs/differences-drv-paths.md
new file mode 100644
index 000000000000..7c811d5cbfef
--- /dev/null
+++ b/tvix/docs/differences-drv-paths.md
@@ -0,0 +1,46 @@
+---
+title: ".drvPath inconsistencies"
+author:
+ - tazjin
+ - flokli
+email:
+ - tazjin@tvl.su
+ - flokli@flokli.de
+lang: en-GB
+---
+
+# Why .drvPath differs between Nix and Tvix
+
+Nix and Tvix currently use a different approach when it comes to tracking input
+references, in order to build the right dependencies in advance.
+Nix is using string contexts, whereas Tvix is doing reference scanning [^inbox-drvpath].
+
+There are some real-life cases, for example during nixpkgs bootstrapping, where
+multiple different fixed-output derivations are written to produce the same
+hash.
+
+For example, bootstrap sources that are downloaded early are fetched using
+a special "builder hack", in which the `builder` field of the derivation is
+populated with the magic string `builtins:fetchurl` and the builder itself will
+perform a fetch, with everything looking like a normal derivation to the user.
+
+These bootstrap sources are later on defined *again*, once `curl`is available,
+to be downloaded using the standard pkgs.fetchtarball mechanism, but yielding
+the *same* outputs (as the same files are being fetched).
+
+In our reference scanning implementation, this output scanning of FOD will
+cause the path of the *first* derivation producing the given fixed output to be
+stored in the `inputDrvs` field of the derivation, while Nix will point to the
+derivation that was actually used.
+
+This doesn't cause any differences in the calculated *output paths*, as paths to
+fixed-output derivations are replaced with a special
+`fixed:out:${algo}:${digest}:${fodPath}` string that doesn't contain the "path
+to the wrong derivation" anymore.
+
+As we haven't fully determined if our reference scanning approach is gonna work,
+and comparing output paths is sufficient to determine equality of the build
+instructions, this is left as a future work item.
+
+
+[^inbox-drvpath]: https://inbox.tvl.su/depot/20230316120039.j4fkp3puzrtbjcpi@tp/T/#t