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

Fix merging stores #31

Closed
deemp opened this issue Mar 11, 2024 · 2 comments
Closed

Fix merging stores #31

deemp opened this issue Mar 11, 2024 · 2 comments

Comments

@deemp
Copy link
Collaborator

deemp commented Mar 11, 2024

We use single-user Nix installation provided by the nix-quick-install-action.

Scenario:

  • There's a store with /nix/var/nix/db.
  • Assume restore-prefixes-all-matches restores a store A, then store B.
    • These stores also have /nix/var/nix/db.
  • Assume B is the last store to be restored.
  • Then, the final store will have /nix/var/nix/db from B.

However, ideally, restore-prefixes-all-matches should really merge stores and databases, not just overwrite databases.

It's currently unclear how to merge stores.

Some links that may be helpful

Reproduce a similar scenario

To get two stores, run

nix build --no-link nixpkgs#hello --store store1
nix build --no-link nixpkgs#gawk --store store2

Then, the databases are in

store1/nix/var/nix/db/db.sqlite
store2/nix/var/nix/db/db.sqlite

I can copy paths from one store to another via cp.

Questions

  • How to merge the databases?
  • Where to merge?
    • In the main near restoreCache
    • Determine whether a cache contains a /nix/var/nix/db/db.sqlite
@deemp deemp changed the title Fix cache merging Fix merging stores Mar 11, 2024
@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/merge-two-nix-stores/41256/1

@deemp
Copy link
Collaborator Author

deemp commented Mar 31, 2024

Should be resolved now. Here's the sql script.

We skip all existing /nix/store paths and all stuff in /nix/var except /nix/var/nix/db/db.sqlite (link).

@deemp deemp closed this as completed Mar 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants