Nix 2.26.3
Nix, the purely functional package manager; unstable internal interfaces
 
Loading...
Searching...
No Matches
store-dir-config.hh
1#pragma once
2
3#include "path.hh"
4#include "hash.hh"
5#include "content-address.hh"
6#include "globals.hh"
7#include "config.hh"
8
9#include <map>
10#include <string>
11#include <variant>
12
13
14namespace nix {
15
16struct SourcePath;
17
18MakeError(BadStorePath, Error);
19MakeError(BadStorePathName, BadStorePath);
20
21struct StoreDirConfig : public Config
22{
23 using Config::Config;
24
25 StoreDirConfig() = delete;
26
27 virtual ~StoreDirConfig() = default;
28
29 const PathSetting storeDir_{this, settings.nixStore,
30 "store",
31 R"(
32 Logical location of the Nix store, usually
33 `/nix/store`. Note that you can only copy store paths
34 between stores if they have the same `store` setting.
35 )"};
36 const Path storeDir = storeDir_;
37
38 // pure methods
39
40 StorePath parseStorePath(std::string_view path) const;
41
42 std::optional<StorePath> maybeParseStorePath(std::string_view path) const;
43
44 std::string printStorePath(const StorePath & path) const;
45
51 StorePathSet parseStorePathSet(const PathSet & paths) const;
52
53 PathSet printStorePathSet(const StorePathSet & path) const;
54
59 std::string showPaths(const StorePathSet & paths);
60
65 bool isInStore(PathView path) const;
66
71 bool isStorePath(std::string_view path) const;
72
77 std::pair<StorePath, Path> toStorePath(PathView path) const;
78
82 StorePath makeStorePath(std::string_view type,
83 std::string_view hash, std::string_view name) const;
84 StorePath makeStorePath(std::string_view type,
85 const Hash & hash, std::string_view name) const;
86
87 StorePath makeOutputPath(std::string_view id,
88 const Hash & hash, std::string_view name) const;
89
90 StorePath makeFixedOutputPath(std::string_view name, const FixedOutputInfo & info) const;
91
92 StorePath makeFixedOutputPathFromCA(std::string_view name, const ContentAddressWithReferences & ca) const;
93
98 std::pair<StorePath, Hash> computeStorePath(
99 std::string_view name,
100 const SourcePath & path,
102 HashAlgorithm hashAlgo = HashAlgorithm::SHA256,
103 const StorePathSet & references = {},
104 PathFilter & filter = defaultPathFilter) const;
105};
106
107}
Definition config.hh:345
Definition path.hh:27
@ NixArchive
Definition file-content-address.hh:114
std::function< bool(const Path &path)> PathFilter
Definition file-system.hh:365
ValueType type
Definition lexer.l:7098
const std::string_view & name
Definition lexer.l:1709
Definition content-address.hh:31
Definition content-address.hh:276
Definition content-address.hh:249
Definition hash.hh:45
Definition source-path.hh:22
StorePathSet parseStorePathSet(const PathSet &paths) const
Definition path.cc:111
StorePath makeStorePath(std::string_view type, std::string_view hash, std::string_view name) const
Definition store-api.cc:80
bool isInStore(PathView path) const
Definition store-api.cc:32
std::pair< StorePath, Hash > computeStorePath(std::string_view name, const SourcePath &path, ContentAddressMethod method=FileIngestionMethod::NixArchive, HashAlgorithm hashAlgo=HashAlgorithm::SHA256, const StorePathSet &references={}, PathFilter &filter=defaultPathFilter) const
Definition store-api.cc:165
std::string showPaths(const StorePathSet &paths)
Definition store-api.cc:1208
bool isStorePath(std::string_view path) const
Definition path.cc:106
std::pair< StorePath, Path > toStorePath(PathView path) const
Definition store-api.cc:38
std::string Path
Definition types.hh:22