aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/indirect-root-store.hh
blob: 59e45af45d404c3efdc30185eb6f633661ea0bc2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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;
};

}