-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Reuse input lock files #7730
Comments
I quite like the syntax @mkenigs used in #4004 to talk about overrides
It is also a useful vehicle for talking about the locking algorithm, which seems that it would recurse into dependencies until the overrides are Similarly, it would probably reflect the |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2023-07-31-nix-team-meeting-minutes-76/31486/1 |
@tomberek My thought on the new lock file format: It should store mappings from unlocked input paths to locked refs, and nothing more, and it shouldn't store input paths that are already locked by the lock files of input flakes. I.e. something like
Thus, if we encounter an unlocked input We don't create lock file entries for "follows" inputs (e.g. if "a.b" follows "c.d", we don't create a lock file entry for "a.b"). In general, we don't store any information in the lock file that is already in flake.nix (except for the "original" refs, which are needed to decide whether we need to update a lock file entry if the corresponding unlocked entry has changed). Note that the above replaces the graph structure of the current lock file format with a simple tree. |
To make |
From NixCon, in discussion with @lheckemann , @infinisil , @roberth
|
One potential consideration for the new format: After @lheckemann's talk I was thinking about a locking algorithm that would handle something like this:
Suppose B and C both depend on nixpkgs. Then locking flake A would store a single revision for nixpkgs and store it in flake A's flake.lock. This is very similar to how language dependency managers like cargo make a distinction between lib and binary dependencies. It might be possible to express the same thing in the current format, by doing e.g.:
But I think that's more difficult, and in practice it seems people often don't add all of the follows they could. It seems like Implementing |
It should in fact be possible with the proposed format, and would be represented on the lockfile side in much the same way as the Note also that ignoring downstream locks would only result in the same nixpkgs being used if the downstream inputs use the same nixpkgs input spec. I hope we can also find an approach (though it need not be implemented inside Nix) that works for replacing references that use different branches, or even different repositories or input types. |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2023-09-18-nix-team-meeting-minutes-87/33194/7 |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2023-09-18-nix-team-meeting-minutes-87/33194/8 |
Yes, except |
This would have to be in the lockfile I think, because it's not present in flake.nix as either a follows or an override (it's a bit more like an implicit follows). Adapting what @edolstra has above, it could be expressed as:
That would result in more duplicated information than the current format. |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/sane-stable-stateless-nixos-setup/35568/3 |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/flake-lock-inadequate/37753/12 |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/flake-lock-inadequate/37753/13 |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/nix-flake-inputs-not-lazy/25463/11 |
Another issue with the current lock file is that it causes nix to needlessly re-evaluates equivalent inputs. For example if we have two inputs However if you want to take advantage of binary caching, then using So if you want to take advantage of binary caching, there's no practical way to avoid re-evaluating inputs. |
I looked into fixing the performance implications of this (without touching the lock file format) in #10218. |
- Simplifies the whole thing due to not having to mess with `system`, see NixOS/nix#3843 - Makes the lockfile _way_ smaller, see NixOS/nix#7730
- Simplifies the whole thing due to not having to mess with `system`, see NixOS/nix#3843 - Makes the lockfile _way_ smaller, see NixOS/nix#7730
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/monorepos-dont-map-to-our-social-structure/44162/18 |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/im-not-convinced-flake-inputs-should-exist/50636/24 |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/how-are-flake-dependencies-fetched/52638/8 |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2024-11-27-nix-team-meeting-minutes-198/56691/1 |
Possible next step: implement overriding in |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/lock-files-without-flakes-what-is-the-status/58297/4 |
|
(was: Solve dev(/test) dependencies and bloated, diverging lock files, by reconsidering the flattened lock file)
Is your feature request related to a problem? Please describe.
We've previously identified issues with the way the lock file currently works.
Describe the solution you'd like
We may consider two scenarios; one with
follows
and one without. Let's start withoutfollows
.Observing that we do not exploit the apparent benefit of knowing all inputs upfront, we may consider loading the required parts of dependency lockfiles on demand.
Example scenario
.
->foo
->nixpkgs
follows
.Evaluation order, current situation:
packages.default
inputs.foo.packages.foo
foo
details from./flake.lock
foo
foo.inputs.nixpkgs
nixpkgs_1
details from local lock filenixpkgs_1
Same evaluation, partial lock file
packages.default
inputs.foo.packages.foo
foo
details from local lock filefoo
foo.inputs.nixpkgs
nixpkgs
details fromfoo/flake.lock
nixpkgs
As you can see, the fetching characteristics remain the same.
Let's reintroduce
follows
, and first consider the example:In other words, this injects the local
nixpkgs
dependency intofoo
. The lazy fetching behavior remains the same. This injection should be handled bycall-flake.nix
and does not require changes to the lock file.Now consider the opposite
follows
:In this case, if we were not to include a copy of
foo.nixpkgs
details in the local lock file, we'd have a slightly worse lazy fetching behavior, asnixpkgs
would only be fetchable afterfoo
's lock has been fetched. For this case, we do want "flat lock file" behavior, but limited to this dependency. The rule for which transitive dependencies to include in the lock file might be as simple as direct inputs + inputs referenced infollows
.This suggests the following implementation strategy:
inputs
are those from its own lock//
those set in the current lockoverrides
parameter incall-flake.nix
that appears to enable this. The missing bit is that some/many nodes would be created by reinvokingcall-flake.nix
rather than sharing the node identifiers. Node identifiers are local to eachcall-flake.nix
call. i.e.overrides
is a prerequisite for calling dependency locks.Describe alternatives you've considered
Mark development dependencies explicitly.
Additional context
Priorities
Add 👍 to issues you find important.
The text was updated successfully, but these errors were encountered: