forked from LnL7/nix
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
101 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
#pragma once | ||
|
||
#include "path.hh" | ||
#include "hash.hh" | ||
#include "content-address.hh" | ||
#include "globals.hh" | ||
#include "config.hh" | ||
|
||
#include <map> | ||
#include <string> | ||
#include <variant> | ||
|
||
|
||
namespace nix { | ||
|
||
MakeError(BadStorePath, Error); | ||
|
||
struct StoreDirConfig : public Config | ||
{ | ||
using Config::Config; | ||
|
||
StoreDirConfig() = delete; | ||
|
||
virtual ~StoreDirConfig() { } | ||
|
||
const PathSetting storeDir_{this, false, settings.nixStore, | ||
"store", "path to the Nix store"}; | ||
const Path storeDir = storeDir_; | ||
|
||
// pure methods | ||
|
||
StorePath parseStorePath(std::string_view path) const; | ||
|
||
std::optional<StorePath> maybeParseStorePath(std::string_view path) const; | ||
|
||
std::string printStorePath(const StorePath & path) const; | ||
|
||
// FIXME: remove | ||
StorePathSet parseStorePathSet(const PathSet & paths) const; | ||
|
||
PathSet printStorePathSet(const StorePathSet & path) const; | ||
|
||
/* Display a set of paths in human-readable form (i.e., between quotes | ||
and separated by commas). */ | ||
std::string showPaths(const StorePathSet & paths); | ||
|
||
/* Return true if ‘path’ is in the Nix store (but not the Nix | ||
store itself). */ | ||
bool isInStore(const Path & path) const; | ||
|
||
/* Return true if ‘path’ is a store path, i.e. a direct child of | ||
the Nix store. */ | ||
bool isStorePath(std::string_view path) const; | ||
|
||
/* Split a path like /nix/store/<hash>-<name>/<bla> into | ||
/nix/store/<hash>-<name> and /<bla>. */ | ||
std::pair<StorePath, Path> toStorePath(const Path & path) const; | ||
|
||
/* Constructs a unique store path name. */ | ||
StorePath makeStorePath(std::string_view type, | ||
std::string_view hash, std::string_view name) const; | ||
StorePath makeStorePath(std::string_view type, | ||
const Hash & hash, std::string_view name) const; | ||
|
||
StorePath makeOutputPath(std::string_view id, | ||
const Hash & hash, std::string_view name) const; | ||
|
||
StorePath makeFixedOutputPath(FileIngestionMethod method, | ||
const Hash & hash, std::string_view name, | ||
const StorePathSet & references = {}, | ||
bool hasSelfReference = false) const; | ||
|
||
StorePath makeTextPath(std::string_view name, const Hash & hash, | ||
const StorePathSet & references = {}) const; | ||
|
||
StorePath makeFixedOutputPathFromCA(std::string_view name, ContentAddress ca, | ||
const StorePathSet & references = {}, | ||
bool hasSelfReference = false) const; | ||
}; | ||
|
||
} |