Support P2P binary cache #289
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
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: lix-project/lix#289
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.
Sometimes the binary cache is down, slow, or otherwise hampered. This makes downloads either slow or impossible.
Describe the solution you'd like
Support a substituter that returns P2P links to binary content e.g IPFS addresses, magnet links, etc.
Describe alternatives you've considered
Host my own binary cache? But I don't know how, and others won't be able to take advantage of it anyway due to the centralised nature.
Additional context
Some people started and stopped implementing it on
nix
but never finished it (maybe Mic92 or K900?). There might be 2 implementation routes allowing protocol handlers to be configured innix.conf
(lix.conf?
)libtorrent
to download torrents, or use IPFS API to download stuff).nar
(or whatever) to a certain location which is then copied into the storeThe later might carry a security and allow putting arbitrary stuff into the store, but you know the ins and outs of this better, so you might already have a mitigation in mind.
that would be really nice to have, but realistically we won't be able to add new substituters any time soon with the current state of the code. there's a stopgap available for now though: local http proxies that turn the substituter protocol nix understands into literally anything else. (in fact one of the things we::horrors would like to do is to do that even for the currently built-in substituters, such that only the nix store protocol remains in the core and substituters can be treated as simple remote stores that can build anything, but don't have any actual build slots)
Is there some kind documentation for the substituter protocol? Is it possible to point
lix
to a HTTP address where the.nar
can be retrieved? As a stopgap for IPFS, for example, the proxy / local substituter could return alocalhost:8888/ipfs/{cid}[/{path}][?{params}]
URL (as described here) that will trigger IPFS download the requested file.I call it stopgap because IPFS would download the file to its own store, then provide it to
lix
that'll in turn put that into its store, thus doubling the space. A solution for the future could be worked on e.g linking or hard-linking to the IPFS store, but that's for later down the road.Could you explain this a little more? I don't understand what you mean by "build anything" and not having any actual build slots. I thought builders took a derivation, built it, and stored the output into the cache, then communicated with substituters to update the mapping of derivation hash --> output hash / download location.
yeah ^^ the issue with the idea of having an IPFS/etc substituter is that currently architecturally this use case would have to be in the core, which is not a pleasant place to write code in the first place.
A local HTTP server implementing the Nix store protocol should make your job much easier in implementing this idea as a prototype without any changes to Lix, and it will let you do it today so you can evaluate how well it works in practice. Also, I don't think that the way that torrents work is at all conducive to nix substitution as a use case, which is currently architecturally very horrible for a protocol that often takes several seconds to start a download, see #19.
The earliest that this feature could possibly be added is probably about a year, and that is highly optimistic on our pace of code improvement. I am marking this as WONTFIX, but it can and perhaps should be re-evaluated in the changed conditions in a year or so.
@loveisgrief Note that https://github.com/tvlfyi/tvix/tree/canon/nar-bridge is an interesting example of such a substituter that you could rework to plug a IPFS/etc. way of doing the bidding. It's used as compatibility glue with a "Tvix store" which has a different model than a classical Nix store.
Thanks both. I wish the substituter protocol were documented, but maybe I'll have to take care of that on nixlang.wiki or something.
Thanks again for the quick responses.
If you want to write up documentation for it and send it to us as a patch, we would take it. There's a
doc/manual/src/protocols/
directory in the docs in Lix where it would reasonably fit.