19#include <nix/eval-cache.hh>
20#include <nix/names.hh>
22#include <nix/symbol-table.hh>
58 bool _hasMetaAttr =
false;
59 bool _hasPnameAttr =
false;
60 bool _hasVersionAttr =
false;
62 std::string _fullName;
65 std::optional<std::string> _semver;
68 std::optional<std::string> _license;
72 init(
bool checkDrv =
true );
85 , _fullName( cursor->getAttr(
"name" )->getString() )
88 nix::DrvName dname( this->_fullName );
89 this->_pname = dname.name;
90 this->_version = dname.version;
92 this->init( checkDrv );
97 : _cursor( cursor ), _fullName( cursor->getAttr(
"name" )->getString() )
100 nix::DrvName dname( this->_fullName );
101 this->_pname = dname.name;
102 this->_version = dname.version;
104 for (
auto & p : symtab->resolve( cursor->getAttrPath() ) )
106 this->_pathS.push_back( p );
108 this->init( checkDrv );
115 std::vector<std::string>
130 return this->_fullName;
140 return this->_cursor;
145 return this->_subtree;
151 return nix::DrvName( this->_fullName );
154 std::optional<std::string>
157 if ( this->_version.empty() ) {
return std::nullopt; }
158 else {
return this->_version; }
161 std::optional<std::string>
164 return this->_semver;
167 std::optional<std::string>
170 if ( this->_license.has_value() ) {
return this->_license; }
171 else {
return std::nullopt; }
174 std::vector<std::string>
177 MaybeCursor o = this->_cursor->maybeGetAttr(
"outputs" );
178 if ( o ==
nullptr ) {
return {
"out" }; }
179 else {
return o->getListOfStrings(); }
182 std::optional<std::string>
185 if ( ! this->_hasMetaAttr ) {
return std::nullopt; }
187 = this->_cursor->getAttr(
"meta" )->maybeGetAttr(
"description" );
188 if ( l ==
nullptr ) {
return std::nullopt; }
191 return l->getString();
213 "error initializing FlakePackage" )
A flox::Package implementation which are pulled from evaluation of a nix flake.
Definition: flake-package.hh:47
std::string getPname() const override
Definition: flake-package.hh:133
std::optional< std::string > getLicense() const override
Definition: flake-package.hh:168
std::vector< std::string > getOutputsToInstall() const override
Definition: flake-package.cc:108
Subtree getSubtreeType() const override
Definition: flake-package.hh:143
std::optional< bool > isBroken() const override
Definition: flake-package.cc:129
std::optional< std::string > getVersion() const override
Definition: flake-package.hh:155
std::optional< std::string > getSemver() const override
Definition: flake-package.hh:162
std::optional< std::string > getDescription() const override
Definition: flake-package.hh:183
std::vector< std::string > getOutputs() const override
Definition: flake-package.hh:175
nix::DrvName getParsedDrvName() const override
Definition: flake-package.hh:149
AttrPath getPathStrs() const override
Definition: flake-package.hh:123
std::optional< bool > isUnfree() const override
Definition: flake-package.cc:146
std::string getFullName() const override
Definition: flake-package.hh:128
An exception thrown when initializing a flox::FlakePackage.
Abstract representation of a "package", analogous to a Nix ‘derivation’.
Definition: package.hh:44
A SQLite3 database used to cache derivation/package information about a single locked flake.
Definition: write.hh:37
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 use by flox.
Definition: command.cc:29
std::shared_ptr< nix::eval_cache::AttrCursor > MaybeCursor
A std::shared_ptr<nix::eval_cache::AttrCursor> which may be nullptr.
Definition: types.hh:47
@ EC_PACKAGE_INIT
Definition: exceptions.hh:55
nix::ref< nix::eval_cache::AttrCursor > Cursor
A non-nullptr std::shared_ptr<nix::eval_cache::AttrCursor>.
Definition: types.hh:50
std::string System
A system pair indicating architecture and platform.
Definition: types.hh:62
std::vector< std::string > AttrPath
A list of key names addressing a location in a nested JSON-like object.
Definition: types.hh:33
Abstract representation of a package.
Miscellaneous typedefs and aliases.