nix-community / cache-nix-action

Cache Nix store in GitHub Actions to speed up workflows [maintainer=@deemp]
MIT License
29 stars 6 forks source link

Fix merging stores #31

Closed deemp closed 2 months ago

deemp commented 3 months ago

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

Scenario:

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

nixos-discourse commented 3 months ago

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 commented 2 months ago

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).