| 1 | #pragma once |
| 2 | |
| 3 | #include <string> |
| 4 | |
| 5 | #include "store-api.hh" |
| 6 | |
| 7 | |
| 8 | namespace nix { |
| 9 | |
| 10 | |
| 11 | class Pipe; |
| 12 | class Pid; |
| 13 | struct FdSink; |
| 14 | struct FdSource; |
| 15 | |
| 16 | |
| 17 | class RemoteStore : public StoreAPI |
| 18 | { |
| 19 | public: |
| 20 | |
| 21 | RemoteStore(); |
| 22 | |
| 23 | ~RemoteStore(); |
| 24 | |
| 25 | /* Implementations of abstract store API methods. */ |
| 26 | |
| 27 | bool isValidPath(const Path & path); |
| 28 | |
| 29 | PathSet queryValidPaths(const PathSet & paths); |
| 30 | |
| 31 | PathSet queryAllValidPaths(); |
| 32 | |
| 33 | ValidPathInfo queryPathInfo(const Path & path); |
| 34 | |
| 35 | Hash queryPathHash(const Path & path); |
| 36 | |
| 37 | void queryReferences(const Path & path, PathSet & references); |
| 38 | |
| 39 | void queryReferrers(const Path & path, PathSet & referrers); |
| 40 | |
| 41 | Path queryDeriver(const Path & path); |
| 42 | |
| 43 | PathSet queryValidDerivers(const Path & path); |
| 44 | |
| 45 | PathSet queryDerivationOutputs(const Path & path); |
| 46 | |
| 47 | StringSet queryDerivationOutputNames(const Path & path); |
| 48 | |
| 49 | Path queryPathFromHashPart(const string & hashPart); |
| 50 | |
| 51 | PathSet querySubstitutablePaths(const PathSet & paths); |
| 52 | |
| 53 | void querySubstitutablePathInfos(const PathSet & paths, |
| 54 | SubstitutablePathInfos & infos); |
| 55 | |
| 56 | Path addToStore(const string & name, const Path & srcPath, |
| 57 | bool recursive = true, HashType hashAlgo = htSHA256, |
| 58 | PathFilter & filter = defaultPathFilter, bool repair = false); |
| 59 | |
| 60 | Path addTextToStore(const string & name, const string & s, |
| 61 | const PathSet & references, bool repair = false); |
| 62 | |
| 63 | void exportPath(const Path & path, bool sign, |
| 64 | Sink & sink); |
| 65 | |
| 66 | Paths importPaths(bool requireSignature, Source & source); |
| 67 | |
| 68 | void buildPaths(const PathSet & paths, BuildMode buildMode); |
| 69 | |
| 70 | void ensurePath(const Path & path); |
| 71 | |
| 72 | void addTempRoot(const Path & path); |
| 73 | |
| 74 | void addIndirectRoot(const Path & path); |
| 75 | |
| 76 | void syncWithGC(); |
| 77 | |
| 78 | Roots findRoots(); |
| 79 | |
| 80 | void collectGarbage(const GCOptions & options, GCResults & results); |
| 81 | |
| 82 | PathSet queryFailedPaths(); |
| 83 | |
| 84 | void clearFailedPaths(const PathSet & paths); |
| 85 | |
| 86 | void optimiseStore(); |
| 87 | |
| 88 | bool verifyStore(bool checkContents, bool repair); |
| 89 | private: |
| 90 | AutoCloseFD fdSocket; |
| 91 | FdSink to; |
| 92 | FdSource from; |
| 93 | unsigned int daemonVersion; |
| 94 | bool initialised; |
| 95 | |
| 96 | void openConnection(bool reserveSpace = true); |
| 97 | |
| 98 | void processStderr(Sink * sink = 0, Source * source = 0); |
| 99 | |
| 100 | void connectToDaemon(); |
| 101 | |
| 102 | void setOptions(); |
| 103 | }; |
| 104 | |
| 105 | |
| 106 | } |