diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2023-03-23 10:06:45 -0400 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2023-07-24 09:19:44 -0400 |
commit | 60d8dd7aeaf7fc022a1b207012c94180f6732b45 (patch) | |
tree | d75c4e83665fe7852938852f3d40908aa8d30784 /src/libstore/indirect-root-store.hh | |
parent | 13269ba93b7453def7084b00eb4a34ad787a7c45 (diff) |
Clean up store hierarchy with `IndirectRootStore`
See the API doc comments for details.
Diffstat (limited to 'src/libstore/indirect-root-store.hh')
-rw-r--r-- | src/libstore/indirect-root-store.hh | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/libstore/indirect-root-store.hh b/src/libstore/indirect-root-store.hh new file mode 100644 index 000000000..59e45af45 --- /dev/null +++ b/src/libstore/indirect-root-store.hh @@ -0,0 +1,48 @@ +#pragma once +///@file + +#include "local-fs-store.hh" + +namespace nix { + +/** + * Mix-in class for implementing permanent roots as a pair of a direct + * (strong) reference and indirect weak reference to the first + * reference. + * + * See methods for details on the operations it represents. + */ +struct IndirectRootStore : public virtual LocalFSStore +{ + inline static std::string operationName = "Indirect GC roots registration"; + + /** + * Implementation of `LocalFSStore::addPermRoot` where the permanent + * root is a pair of + * + * - The user-facing symlink which all implementations must create + * + * - An additional weak reference known as the "indirect root" that + * points to that symlink. + * + * The garbage collector will automatically remove the indirect root + * when it finds that the symlink has disappeared. + * + * The implementation of this method is concrete, but it delegates + * to `addIndirectRoot()` which is abstract. + */ + Path addPermRoot(const StorePath & storePath, const Path & gcRoot) override final; + + /** + * Add an indirect root, which is a weak reference to the + * user-facing symlink created by `addPermRoot()`. + * + * @param path user-facing and user-controlled symlink to a store + * path. + * + * The form this weak-reference takes is implementation-specific. + */ + virtual void addIndirectRoot(const Path & path) = 0; +}; + +} |