Flox Package Database 1
CRUD Operations on Nix Package Metadata
Loading...
Searching...
No Matches
db-package.hh
Go to the documentation of this file.
1/* ========================================================================== *
2 *
3 * @file flox/pkgdb/db-package.hh
4 *
5 * @brief Package metadata loaded from a `PkgDb' cache.
6 *
7 *
8 * -------------------------------------------------------------------------- */
9
10#pragma once
11
12#include <filesystem>
13#include <string>
14
15#include <nix/flake/flakeref.hh>
16
17#include "flox/core/types.hh"
19#include "flox/pkgdb/read.hh"
20#include "flox/raw-package.hh"
21
22
23/* -------------------------------------------------------------------------- */
24
25namespace flox::pkgdb {
26
27/* -------------------------------------------------------------------------- */
28
30class DbPackage : public RawPackage
31{
32
33protected:
34
35 /* From `RawPackage':
36 * AttrPath path;
37 * std::string name;
38 * std::string pname;
39 * std::optional<std::string> version;
40 * std::optional<std::string> semver;
41 * std::optional<std::string> license;
42 * std::vector<std::string> outputs;
43 * std::vector<std::string> outputsToInstall;
44 * std::optional<bool> broken;
45 * std::optional<bool> unfree;
46 * std::optional<std::string> description;
47 */
48
50 std::filesystem::path dbPath;
52private:
53
55 void
57
58
59public:
60
62 : pkgId( pkgId ), dbPath( pkgdb.dbPath )
63 {
64 this->path = pkgdb.getPackagePath( pkgId );
65 this->initRawPackage( pkgdb );
66 }
67
68 DbPackage( PkgDbReadOnly & pkgdb, const AttrPath & path )
69 : pkgId( pkgdb.getPackageId( path ) ), dbPath( pkgdb.dbPath )
70 {
71 this->path = path;
72 this->initRawPackage( pkgdb );
73 }
74
76 row_id
78 {
79 return this->pkgId;
80 }
81
83 std::filesystem::path
84 getDbPath() const
85 {
86 return this->dbPath;
87 }
88
90 nix::FlakeRef
92 {
93 return PkgDbReadOnly( this->dbPath.string() ).getLockedFlakeRef();
94 }
95
96}; /* End class `DbPackage' */
97
98
99/* -------------------------------------------------------------------------- */
100
101} // namespace flox::pkgdb
102
103
104/* -------------------------------------------------------------------------- *
105 *
106 *
107 *
108 * ========================================================================== */
The simplest ‘Package’ implementation comprised of raw values.
Definition: raw-package.hh:35
Package metadata loaded from a ‘PkgDb’ cache.
Definition: db-package.hh:31
std::filesystem::path getDbPath() const
Definition: db-package.hh:84
row_id getPackageId() const
Definition: db-package.hh:77
void initRawPackage(PkgDbReadOnly &pkgdb)
Fill flox::RawPackage fields by reading them from pkgdb.
Definition: db-package.cc:21
nix::FlakeRef getLockedFlakeRef() const
Definition: db-package.hh:91
std::filesystem::path dbPath
Definition: db-package.hh:50
row_id pkgId
Definition: db-package.hh:49
A SQLite3 database used to cache derivation/package information about a single locked flake.
Definition: read.hh:135
flox::AttrPath getPackagePath(row_id row)
Get the attribute path for a given Packages.id.
Definition: read.cc:343
Interfaces for caching package metadata in SQLite3 databases.
Definition: command.cc:44
uint64_t row_id
Definition: pkg-query.hh:48
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 constructing complex ‘Packages’ queries.
The simplest ‘Package’ implementation comprised of raw values.
Interfaces for reading a SQLite3 package set database.
Miscellaneous typedefs and aliases.