18#include <nix/eval-cache.hh>
19#include <nix/flake/flake.hh>
20#include <nlohmann/json.hpp>
21#include <sqlite3pp.hh>
33#ifndef FLOX_PKGDB_VERSION
34# define FLOX_PKGDB_VERSION "NO.VERSION"
66 return ( this->tables == other.
tables ) && ( this->views == other.
views );
73 return ! ( ( *this ) == other );
94using SQLiteDb = sqlite3pp::database;
150 nlohmann::json attrs = nlohmann::json::object();
164 std::string(
"No such database '" + pdb.
dbPath.string() +
"'." ) )
211 : fingerprint( nix::htSHA256 )
225 : fingerprint( fingerprint ), dbPath( dbPath )
275 completedAttrSet(
row_id row );
295 getAttrSetPath(
row_id row );
314 getPackagePath(
row_id row );
334 getDescription(
row_id descriptionId );
345 getPackages(
const PkgQueryArgs & params );
373 getLockedFlakeRef()
const
375 return nix::FlakeRef::fromAttrs(
376 nix::fetchers::jsonToAttrs( this->lockedRef.attrs ) );
A generic exception thrown by flox::pkgdb::* classes.
A SQLite3 database used to cache derivation/package information about a single locked flake.
Definition: read.hh:135
Fingerprint fingerprint
Definition: read.hh:141
PkgDbReadOnly(const Fingerprint &fingerprint, std::string_view dbPath)
Opens a DB directly by its fingerprint hash.
Definition: read.hh:224
std::filesystem::path dbPath
Definition: read.hh:142
PkgDbReadOnly(std::string_view dbPath)
Opens an existing database.
Definition: read.hh:210
PkgDbReadOnly()
Dummy constructor required for child classes so that they can open databases in read-only mode.
Definition: read.hh:199
SQLiteDb db
Definition: read.hh:143
PkgDbReadOnly(const Fingerprint &fingerprint)
Opens a DB directly by its fingerprint hash.
Definition: read.hh:236
Restricts template parameters to classes that extend flox::pkgdb::PkgDbReadOnly.
Definition: read.hh:390
Executable command helpers, argument parsers, etc.
Definitions of various std::exception children used for throwing errors with nice messages and typed ...
#define FLOX_DEFINE_EXCEPTION(NAME, ERROR_CODE, CATEGORY_MSG)
Generate a class definition with an error code and category message.
Definition: exceptions.hh:206
Interfaces for caching package metadata in SQLite3 databases.
Definition: command.cc:44
std::filesystem::path genPkgDbName(const Fingerprint &fingerprint, const std::filesystem::path &cacheDir)
Get an absolute path to the ‘PkgDb’ for a given fingerprint hash.
Definition: read.cc:76
std::filesystem::path getPkgDbCachedir()
Get the default pkgdb cache directory to save databases.
Definition: read.cc:53
nix::flake::Fingerprint Fingerprint
Definition: read.hh:93
uint64_t row_id
Definition: pkg-query.hh:48
int sql_rc
Definition: read.hh:95
bool isSQLError(int rcode)
Predicate to detect failing SQLite3 return codes.
Definition: read.cc:29
std::ostream & operator<<(std::ostream &oss, const SqlVersions &versions)
Emit version information to an output stream.
Definition: read.cc:44
constexpr SqlVersions sqlVersions
Definition: read.hh:87
@ EC_PKG_DB
Definition: exceptions.hh:63
std::vector< std::string > AttrPath
A list of key names addressing a location in a nested JSON-like object.
Definition: types.hh:33
Interfaces for analyzing version numbers.
Definition: versions.cc:31
Abstract representation of a package.
Interfaces for constructing complex ‘Packages’ queries.
Locked flake reference for database's flake.
Definition: read.hh:147
std::string string
Definition: read.hh:148
Thrown when a database is not found.
Definition: read.hh:161
SQLite3 schema versions.
Definition: read.hh:47
constexpr bool operator!=(const SqlVersions &other) const
Definition: read.hh:71
unsigned tables
Definition: read.hh:53
unsigned views
Definition: read.hh:60
constexpr bool operator==(const SqlVersions &other) const
Definition: read.hh:64
friend std::ostream & operator<<(std::ostream &oss, const SqlVersions &versions)
Emit version information to an output stream.
Definition: read.cc:44
Miscellaneous typedefs and aliases.