Flox Package Database 1
CRUD Operations on Nix Package Metadata
Loading...
Searching...
No Matches
flox-flake.hh
Go to the documentation of this file.
1/* ========================================================================== *
2 *
3 * @file flox/flox-flake.hh
4 *
5 * @brief Defines a convenience wrapper that provides various operations on
6 * a `flake`.
7 *
8 *
9 * -------------------------------------------------------------------------- */
10
11#pragma once
12
13#include <memory>
14#include <nix/eval.hh>
15#include <nix/flake/flake.hh>
16#include <vector>
17
18#include <nlohmann/json.hpp>
19
22#include "flox/core/types.hh"
23
24
25/* -------------------------------------------------------------------------- */
26
27namespace flox {
28
29/* -------------------------------------------------------------------------- */
30
37static const nix::flake::LockFlags defaultLockFlags = {
38 .recreateLockFile = false /* default */
39 ,
40 .updateLockFile = false,
41 .writeLockFile = false,
42 .useRegistries = std::nullopt /* default */
43 ,
44 .applyNixConfig = false /* default */
45 ,
46 .allowUnlocked = true /* default */
47 ,
48 .commitLockFile = false /* default */
49 ,
50 .referenceLockFilePath = std::nullopt /* default */
51 ,
52 .outputLockFilePath = std::nullopt /* default */
53 ,
54 .inputOverrides = {} /* default */
55 ,
56 .inputUpdates = {} /* default */
57};
58
59
60/* -------------------------------------------------------------------------- */
61
71class FloxFlake : public std::enable_shared_from_this<FloxFlake>
72{
73
74private:
75
81 std::shared_ptr<nix::eval_cache::EvalCache> _cache;
82
83public:
84
85 nix::ref<nix::EvalState> state;
86 const nix::flake::LockedFlake lockedFlake;
87
88 FloxFlake( const nix::ref<nix::EvalState> & state,
89 const nix::FlakeRef & ref );
90
96 nix::ref<nix::eval_cache::EvalCache>
98
107 maybeOpenCursor( const AttrPath & path );
108
115 Cursor
116 openCursor( const AttrPath & path );
117
118}; /* End class `FloxFlake' */
119
120/* -------------------------------------------------------------------------- */
121
130 "error locking flake" )
134/* -------------------------------------------------------------------------- */
135
136} // namespace flox
137
138
139/* -------------------------------------------------------------------------- *
140 *
141 *
142 *
143 * ========================================================================== */
Definition: flox-flake.hh:72
MaybeCursor maybeOpenCursor(const AttrPath &path)
Definition: flox-flake.cc:94
std::shared_ptr< nix::eval_cache::EvalCache > _cache
Definition: flox-flake.hh:81
Cursor openCursor(const AttrPath &path)
Definition: flox-flake.cc:109
nix::ref< nix::eval_cache::EvalCache > openEvalCache()
Definition: flox-flake.cc:64
An exception thrown when locking a flake.
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
static const nix::flake::LockFlags defaultLockFlags
Definition: flox-flake.hh:37
@ EC_NIX_LOCK_FLAKE
Definition: exceptions.hh:53
nix::ref< nix::eval_cache::AttrCursor > Cursor
A non-nullptr std::shared_ptr<nix::eval_cache::AttrCursor>.
Definition: types.hh:50
std::vector< std::string > AttrPath
A list of key names addressing a location in a nested JSON-like object.
Definition: types.hh:33
Manages a nix runtime state blob with associated helpers.
Miscellaneous typedefs and aliases.