zhaofengli / attic

Multi-tenant Nix Binary Cache
https://docs.attic.rs
Other
965 stars 73 forks source link

Document full cache option #82

Open jpds opened 1 year ago

jpds commented 1 year ago

The tutorial states in the pushing section:

The interesting thing is that attic automatically skipped over store paths cached by cache.nixos.org! This behavior can be configured on a per-cache basis.

However, I'm interesting in using attic which everything is pushed up to the cache so that everything is pulled down from the LAN without having to reach out to the Internet.

I've tried setting my local cache to have a higher priority of 30 than the cache.nixos.org 40 value. However, my test machine would still pull from there.

The only way I've found to force a client to use the local cache is to comment out the substituters line to be:

substituters = http://localhost:8080/hello #https://cache.nixos.org

...however I'm not sure if this would break anything else.

cole-h commented 10 months ago

It should be as simple as setting the upstream cache keys to an empty string, either when you create the cache with attic cache create name --upstream-cache-key-name '', or after you've created the cache with attic cache configure name --upstream-cache-key-name ''. At that point, as long as your cache appears before cache.nixos.org in the substituters list, it should only use your local cache except when it doesn't have a path.

JulienMalka commented 10 months ago

Yes, it should be. However nix has a cache of substituters priorities that has I think one week of TTL. Your option is that case is to go and directly delete that entry in the nix sqlite database.