aboutsummaryrefslogtreecommitdiff
path: root/src/libfetchers/tree-info.cc
blob: 50795e1621a52e189090aab3422eefe9817c71d8 (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
#include "tree-info.hh"
#include "store-api.hh"

#include <nlohmann/json.hpp>

namespace nix::fetchers {

StorePath TreeInfo::computeStorePath(Store & store) const
{
    assert(narHash);
    return store.makeFixedOutputPath(true, narHash, "source");
}

nlohmann::json TreeInfo::toJson() const
{
    nlohmann::json json;
    assert(narHash);
    json["narHash"] = narHash.to_string(SRI);
    if (revCount)
        json["revCount"] = *revCount;
    if (lastModified)
        json["lastModified"] = *lastModified;
    return json;
}

}