Evaluation result is not cached for multiple nix subcommands #925
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
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
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: lix-project/lix#925
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?
Describe the bug
Evaluating a derivation with flakes doesn't populate the eval cache.
If you have a problem with a specific package or NixOS,
you probably want to file an issue at https://github.com/NixOS/nixpkgs/issues.
Steps To Reproduce
~/.cache/nix/eval-cache-v5
if the following steps are already cached somehow)time nix eval nixpkgs/e364990b50adfbb8c32c1316903652f37834538c#firefox
Expected behavior
Running the second command should be much quicker
nix --version
outputAdditional context
I'm getting varying results with
nix eval
(some data gets written to the eval cache db)nix shell
(only an empty table gets created in eval cache db) andnix build
(seems to work well, but only for some flakes, maybe it's about pinning?)My main problem I'm trying to solve, is evaluating our server configuration on a slower Raspberry Pi 4 takes 3-4 minutes. This configuration uses some flakes that steal ~70% of the eval time, and I'd like them to be cached. First, I want to understand why is Lix not caching even a single flake output with
nix eval
.I've attached the output of
nix eval nixpkgs/e364990b50adfbb8c32c1316903652f37834538c#firefox -vvvv
.Nothing is saved to eval-cache databasesto Evaluation result is not cached for multiple nix subcommandsthe eval cache mechanism is indeed very badly busted, and it's possible that it cannot be fixed at all. your test case of evaluating eg firefox can probably be cached with enough reworking of the cache infrastructure, but due to how the system works today it is completely impossible to cache partial evaluation results in the way you're asking. the flake eval cache is applied at the very end of the process, it's an all-or-nothing deal. (yes, flakes are Absolutely Perfect In Every Single Imaginable Way like that.)
we do have plans to fix all of this, but it's a long way out. caching shells the way we cache built installables is in theory possible, doing it for eval in general is not feasible because the cache drops far too much data.
Thanks for the explanation :)
Unfortunate that this is the state of flake eval caching, I think I'll try to implement a similar hack to https://github.com/DavHau/nix-eval-cache/blob/main/lib.nix, which puts the evaled values in a derivation which is cached. With this implementation, my problem was that it relied on
pkgs
to build that derivation in a way thatnixpkgs
had to be copied to the store on every eval. At least it cuts down all the eval time to the time of copying nixpkgs to the store, which is ~5 seconds on my drive.