RFD: deprecate and remove fetch-closure
experimental feature #1010
Labels
No labels
Affects/CppNix
Affects/Nightly
Affects/Only nightly
Affects/Stable
Area/build-packaging
Area/cli
Area/evaluator
Area/fetching
Area/flakes
Area/language
Area/lix ci
Area/nix-eval-jobs
Area/profiles
Area/protocol
Area/releng
Area/remote-builds
Area/repl
Area/repl/debugger
Area/store
bug
Context
contributors
Context
drive-by
Context
maintainers
Context
RFD
crash 💥
Cross Compilation
devx
docs
Downstream Dependents
E/easy
E/hard
E/help wanted
E/reproducible
E/requires rearchitecture
Feature/S3
imported
Language/Bash
Language/C++
Language/NixLang
Language/Python
Language/Rust
Needs Langver
OS/Linux
OS/macOS
performance
regression
release-blocker
stability
Status
blocked
Status
invalid
Status
postponed
Status
wontfix
testing
testing/flakey
Topic/Large Scale Installations
ux
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: lix-project/lix#1010
Loading…
Add table
Add a link
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?
fetchClosure
is a new built-in that appeared in 2022 in CppNix 2.8.0.Its description in the release notes are as follows:
In practice,
fetchClosure
knows how to do more than that:Users of
fetchClosure
as far as I could tell are:Both use cases are somewhat of an antipattern in Nix semantics. If the user cannot fetch a program directly via the substituter mechanism and fall back to local build, this is a feature AND a misconfiguration. If the user cannot build certain derivations because they are too expensive, the build directives should pass
-j0
or similar.As for the second usecase, there's a different way to do it that also allows to have a way to reproduce the paths that are hardcoded in that file, perform
import (fetchurl "https://my-cache/${hashparts storepath}.drv")
rather, i.e. an IFD to a possibly well known name. The backend can generate them on the fly or once, and possess stable names.Finally, as for the non-CA → CA features, Lix removed
ca-derivations
.fetchClosure
offersca-derivations
-like features which suffers from similar shortcomings albeit lessened. It only follows that we should rather deprecate and remove these capabilities.Proposed timeline:
fetchClosure
(deprecated-features
in 2.94.0)fetchClosure
on the next release (2.95.0)fetchurl is not actually IFD! the fetch runs during eval, creating creating an immediate store path that is not a derivation output. and the ca rewriting things absolutely should go away, they're broken. we'd also like to get rid of
make-content-addressed
, but, yeah.unfortunately it also turns out that it isn't actually this simple. importing drv files and getting runtime derivation back only works on files that are already in the store. we would still need a variant of fetchClosure to make these appear if we wanted to do it with straight
import
. there's also the option of having a smarter cache that returns json-formatted derivation objects that are reconstituted after fetch, but that's even more horrid than import. we could do actual ifd to materialize the derivations and then import them though, likeseq (readFile (toDerivation drvpath)) (import drvpath)
with toDerivation from nixpkgs lib. this seems to work perfectly fine and causes a ton of substitution, but no build or eval activity as such. this trick works more directly with store paths (where toDerivation directly creates a substitutable entity from a non-present store path as long as some substituters has it), no ifd required. the latter also has the nice side effect of substitutions not happening during eval, which can speed things up significantly.tl;dr we don't even need to go through importing drvs, just slamming a store path into a derivation-ish set emulates fetchClosure (excluding ca rewrites) pretty well. it also doesn't block eval, which makes it superior to fetchClosure in every meaningful way
I have an unusual use case for this: at work we're building store paths with references and ca metadata from buck2 targets, which are totally opaque to nix because they are imported directly into the store and there's absolutely no way to express them as a derivation. Currently to consume these from nix language, we use appendContext crimes, but I've not at all checked whether substitution of these opaque paths works. It's possible that we could use this builtin but we're only likely to do that if it is found to be mandatory as experimental features are preferable to avoid.
We do not support self references and we have no intent to use the rewrite mechanism in any way; these are morally just FODs with references.
you can
toDerivation aStorePathThatExistsOnSomeCache
and receive an object that is substitutable with that store path and collapses to that store path in most places. all non-technical store paths can be substituted, opaque or not, which is also why you can do and receive error messages like this (because cno doesn't cache drvs):