Skip to content
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

Make nix flake metadata|update|lock lazy #12432

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

edolstra
Copy link
Member

@edolstra edolstra commented Feb 6, 2025

Motivation

These don't need to evaluate anything (except for the flake metadata in flake.nix) so we can make these commands operate on lazy trees (i.e. without having to copy the inputs to the store) without risk of any semantic change in the evaluator.

However, as a result, nix flake metadata now no longer prints the store path, which is a breaking change (but unavoidable if we want lazy trees). So calls like nix flake metadata --json | jq .path should be replaced by nix flake prefetch --json | jq .storePath.

Depends on #12421.

TODO: add release note.

Context


Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

@github-actions github-actions bot added new-cli Relating to the "nix" command with-tests Issues related to testing. PRs with tests have some priority fetching Networking with the outside (non-Nix) world, input locking labels Feb 6, 2025
@roberth
Copy link
Member

roberth commented Feb 7, 2025

👍

no longer prints the store path, which is a breaking change (but unavoidable if we want lazy trees)

This could still be done by hashing without copying, but that behavior is still slower than ideal, so it should be removed (as you did) or be put behind a flag perhaps if it is needed. I feel like it's not "metadata" though.

Copy link
Member

@roberth roberth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This introduces some new code paths for which it would have been nice to remove the old, strict / copying ones, but that'd be too soon. Looks ok.

src/libexpr/eval.cc Outdated Show resolved Hide resolved
src/libflake/flake/flake.cc Outdated Show resolved Hide resolved
src/libflake/flake/flake.cc Outdated Show resolved Hide resolved
src/libflake/flake/flake.cc Outdated Show resolved Hide resolved
@edolstra edolstra requested a review from Ericson2314 as a code owner February 7, 2025 14:10
@github-actions github-actions bot added the store Issues and pull requests concerning the Nix store label Feb 7, 2025
Copy link

dpulls bot commented Feb 10, 2025

🎉 All dependencies have been resolved !

These don't need to evaluate anything (except for the flake metadata
in flake.nix) so we can make these commands operate on lazy trees
without risk of any semantic change in the evaluator.

However, `nix flake metadata` now no longer prints the store path,
which is a breaking change (but unavoidable if we want lazy trees).
For the top-level flake, we don't need a NAR hash. But for inputs, we
do.

Also, add a test for the lazy behaviour of `nix flake metadata|lock`.
@edolstra edolstra force-pushed the lazy-flake-commands branch from a15123a to 2890a2e Compare February 10, 2025 17:05
@edolstra edolstra requested a review from roberth February 13, 2025 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fetching Networking with the outside (non-Nix) world, input locking new-cli Relating to the "nix" command store Issues and pull requests concerning the Nix store with-tests Issues related to testing. PRs with tests have some priority
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants