Nix 2.36.0
Nix, the purely functional package manager; unstable internal interfaces
Loading...
Searching...
No Matches
store-dir-config.hh
1#pragma once
2
3#include "nix/store/path.hh"
5#include "nix/util/hash.hh"
8
9#include <map>
10#include <string>
11#include <variant>
12
13namespace nix {
14
15struct SourcePath;
16
29{
30 const std::string & storeDir;
31
32 // pure methods
33
34 StorePath parseStorePath(std::string_view path) const;
35
43 StorePath parseStorePathCanonical(std::string_view path) const;
44
45 std::optional<StorePath> maybeParseStorePath(std::string_view path) const;
46
47 std::string printStorePath(const StorePath & path) const;
48
49 StringSet printStorePathSet(const StorePathSet & path) const;
50
51 std::size_t maxCanonicalStorePathLen() const noexcept
52 {
53 /* storeDir itself must be canonical + "/" + StorePath basename. */
54 return storeDir.size() + 1 + StorePath::MaxBasenameLen;
55 }
56
65 bool isInStore(std::string_view path) const;
66
71 bool isStorePath(std::string_view path) const;
72
77 std::pair<StorePath, CanonPath> toStorePath(std::string_view path) const;
78
82 StorePath makeStorePath(std::string_view type, std::string_view hash, std::string_view name) const;
83 StorePath makeStorePath(std::string_view type, const Hash & hash, std::string_view name) const;
84
85 StorePath makeOutputPath(std::string_view id, const Hash & hash, std::string_view name) const;
86
87 StorePath makeFixedOutputPath(std::string_view name, const FixedOutputInfo & info) const;
88
89 StorePath makeFixedOutputPathFromCA(std::string_view name, const ContentAddressWithReferences & ca) const;
90
95 std::pair<StorePath, Hash> computeStorePath(
96 std::string_view name,
97 const SourcePath & path,
99 HashAlgorithm hashAlgo = HashAlgorithm::SHA256,
100 const StorePathSet & references = {},
101 PathFilter & filter = defaultPathFilter) const;
102};
103
104} // namespace nix
Definition path.hh:33
static constexpr size_t MaxBasenameLen
Maximum length of the basename admitted by the constructor from a string.
Definition path.hh:53
fun< bool(const std::string &path)> PathFilter
Definition file-system.hh:494
Definition content-address.hh:32
@ NixArchive
Definition content-address.hh:51
Definition content-address.hh:284
Definition content-address.hh:257
Definition hash.hh:58
Definition source-path.hh:22
Definition store-dir-config.hh:29
bool isInStore(std::string_view path) const
Definition store-api.cc:133
StorePath parseStorePathCanonical(std::string_view path) const
Definition store-dir-config.cc:34
StorePath makeStorePath(std::string_view type, std::string_view hash, std::string_view name) const
Definition store-dir-config.cc:85
std::pair< StorePath, Hash > computeStorePath(std::string_view name, const SourcePath &path, ContentAddressMethod method=ContentAddressMethod::Raw::NixArchive, HashAlgorithm hashAlgo=HashAlgorithm::SHA256, const StorePathSet &references={}, PathFilter &filter=defaultPathFilter) const
Definition store-dir-config.cc:164
std::pair< StorePath, CanonPath > toStorePath(std::string_view path) const
Definition store-api.cc:138
bool isStorePath(std::string_view path) const
Definition store-dir-config.cc:58
std::set< std::string, std::less<> > StringSet
Definition types.hh:45