Flox Package Database 1
CRUD Operations on Nix Package Metadata
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
flox::resolver::Environment Class Reference

A collection of data associated with an environment and its state. More...

#include <environment.hh>

Inheritance diagram for flox::resolver::Environment:
flox::NixStoreMixin

Public Member Functions

 Environment (std::optional< GlobalManifest > globalManifest, EnvironmentManifest manifest, std::optional< Lockfile > oldLockfile, Upgrades upgrades=false)
 
 Environment (EnvironmentManifest manifest, std::optional< Lockfile > oldLockfile=std::nullopt)
 
const std::optional< GlobalManifest > & getGlobalManifest () const
 
std::optional< GlobalManifestRawgetGlobalManifestRaw () const
 
const EnvironmentManifestgetManifest () const
 
const ManifestRawgetManifestRaw () const
 
std::optional< ManifestRawgetOldManifestRaw () const
 Get the old manifest from oldLockfile if it exists.
 
std::optional< LockfilegetOldLockfile () const
 
RegistryRawgetCombinedRegistryRaw ()
 Get a merged form of oldLockfile ( if available ), globalManifest ( if available ) and manifest registries.
 
const pkgdb::PkgQueryArgs & getCombinedBaseQueryArgs ()
 Get a base set of flox::pkgdb::PkgQueryArgs from combined options.
 
std::vector< SystemgetSystems () const
 Get the set of supported systems.
 
nix::ref< Registry< pkgdb::PkgDbInputFactory > > getPkgDbRegistry ()
 Lazily initialize and get the combined registry's DBs.
 
Lockfile createLockfile ()
 Create a new lockfile from manifest.
 

Protected Member Functions

std::optional< LockedInputRaw > getGroupInput (const InstallDescriptors &group, const Lockfile &oldLockfile, const System &system) const
 Get locked input from a lockfile to try to use to resolve a group of packages.
 
bool groupIsLocked (const InstallDescriptors &group, const Lockfile &oldLockfile, const System &system) const
 Check if lock from @ oldLockfile can be reused for a group.
 

Private Types

using Upgrades = std::variant< bool, std::vector< InstallID > >
 Indicator for lockfile upgrade operations.
 

Private Member Functions

std::vector< InstallDescriptorsgetUnlockedGroups (const System &system)
 Get groups that need to be locked as opposed to reusing locks from oldLockfile.
 
std::vector< InstallDescriptorsgetLockedGroups (const System &system)
 Get groups with locks that can be reused from oldLockfile.
 
const OptionsgetCombinedOptions ()
 Get a merged form of oldLockfile or globalManifest ( if available ) and manifest options.
 
std::optional< pkgdb::row_idtryResolveDescriptorIn (const ManifestDescriptor &descriptor, const pkgdb::PkgDbInput &input, const System &system)
 Try to resolve a descriptor in a given package database.
 
ResolutionResult tryResolveGroup (const InstallDescriptors &group, const System &system)
 Try to resolve a group of descriptors.
 
std::variant< InstallID, SystemPackages > tryResolveGroupIn (const InstallDescriptors &group, const pkgdb::PkgDbInput &input, const System &system)
 Try to resolve a group of descriptors in a given package database.
 
void lockSystem (const System &system)
 Lock all descriptors for a given system. This is a helper function of flox::resolver::Environment::createLockfile().
 
- Private Member Functions inherited from flox::NixStoreMixin
 NixStoreMixin (const NixStoreMixin &)=default
 
 NixStoreMixin (NixStoreMixin &&)=default
 
NixStoreMixinoperator= (const NixStoreMixin &)=default
 
NixStoreMixinoperator= (NixStoreMixin &&)=default
 
 NixStoreMixin (const nix::ref< nix::Store > &store)
 Construct NixStoreMixin from an existing store connection.
 
 NixStoreMixin ()
 Construct NixStoreMixin using the systems default nix store.
 
nix::ref< nix::Store > getStore ()
 Lazily open a nix store connection.
 

Static Private Member Functions

static LockedPackageRaw lockPackage (const LockedInputRaw &input, pkgdb::PkgDbReadOnly &dbRO, pkgdb::row_id row, unsigned priority)
 
static LockedPackageRaw lockPackage (const pkgdb::PkgDbInput &input, pkgdb::row_id row, unsigned priority)
 

Private Attributes

std::optional< GlobalManifestglobalManifest
 
EnvironmentManifest manifest
 
std::optional< LockfileoldLockfile
 
Upgrades upgrades
 
std::optional< LockfileRawlockfileRaw
 
std::optional< RegistryRawcombinedRegistryRaw
 
std::optional< OptionscombinedOptions
 
std::optional< pkgdb::PkgQueryArgs > combinedBaseQueryArgs
 
std::optional< RegistryRawlockedRegistry
 
std::shared_ptr< Registry< pkgdb::PkgDbInputFactory > > dbs
 

Detailed Description

A collection of data associated with an environment and its state.

This structure provides a number of helper routines which require knowledge of manifests and lockfiles together - most importantly, locking descriptors.

See also
flox::resolver::GlobalManifest
flox::resolver::Manifest
flox::resolver::Lockfile

Member Typedef Documentation

◆ Upgrades

using flox::resolver::Environment::Upgrades = std::variant<bool, std::vector<InstallID> >
private

Indicator for lockfile upgrade operations.

true means upgrade everything. false or an empty vector mean upgrade nothing. A list of InstallIDs indicates a subset of packages to be upgraded.

Member Function Documentation

◆ getCombinedOptions()

const Options & flox::resolver::Environment::getCombinedOptions ( )
private

Get a merged form of oldLockfile or globalManifest ( if available ) and manifest options.

Global options have the lowest priority, and will be clobbered by locked options. Options defined in the current manifest have the highest priority and will clobber all other settings.

◆ getCombinedRegistryRaw()

RegistryRaw & flox::resolver::Environment::getCombinedRegistryRaw ( )

Get a merged form of oldLockfile ( if available ), globalManifest ( if available ) and manifest registries.

The Global registry has the lowest priority, and will be clobbered by locked registry inputs/settings. The registry defined in the current manifest has the highest priority and will clobber all other inputs/settings.

◆ getGroupInput()

std::optional< LockedInputRaw > flox::resolver::Environment::getGroupInput ( const InstallDescriptors group,
const Lockfile oldLockfile,
const System system 
) const
protected

Get locked input from a lockfile to try to use to resolve a group of packages.

Helper function for flox::resolver::Environment::lockSystem. Choosing the locked input for a group is full of edge cases, because the new group may be different than whatever was in the group in the old lockfile. We still want to reuse old locked inputs when we can. For example:

  • If the group name has changed, but nothing else has, we want to use the locked input.
  • If packages have been added to a group, we want to use the locked input from a package that was already in the group.
  • If groups are combined into a new group with a new name, we want to try to use one of the old locked inputs ( for now we just use the first one we find ).

If, on the other hand, a package has changed, we don't want to use its locked input.

Returns
a locked input related to the group if we can find one, otherwise std::nullopt.

◆ groupIsLocked()

bool flox::resolver::Environment::groupIsLocked ( const InstallDescriptors group,
const Lockfile oldLockfile,
const System system 
) const
protected

Check if lock from @ oldLockfile can be reused for a group.

Checks if:

  • All descriptors are present in the old manifest.
  • No descriptors have changed in the old manifest such that the lock is invalidated.
  • All descriptors are present in the old lock

◆ lockSystem()

void flox::resolver::Environment::lockSystem ( const System system)
private

Lock all descriptors for a given system. This is a helper function of flox::resolver::Environment::createLockfile().

This must be called after lockfileRaw is initialized. This is only intended to be called from flox::resolver::Environment::createLockfile().

◆ tryResolveGroup()

ResolutionResult flox::resolver::Environment::tryResolveGroup ( const InstallDescriptors group,
const System system 
)
private

Try to resolve a group of descriptors.

Attempts to resolve using a locked input from the old lockfile if it exists for the group. If not, inputs from the combined environment registry are used.

Returns
std::nullopt if resolution fails, otherwise a set of resolved packages.

◆ tryResolveGroupIn()

std::variant< InstallID, SystemPackages > flox::resolver::Environment::tryResolveGroupIn ( const InstallDescriptors group,
const pkgdb::PkgDbInput input,
const System system 
)
private

Try to resolve a group of descriptors in a given package database.

Returns
InstallID of the package that can't be resolved if resolution fails, otherwise a set of resolved packages for the system.

Member Data Documentation

◆ globalManifest

std::optional<GlobalManifest> flox::resolver::Environment::globalManifest
private

Contents of user level manifest with global registry and settings.

◆ lockedRegistry

std::optional<RegistryRaw> flox::resolver::Environment::lockedRegistry
private

A registry of locked inputs.

◆ lockfileRaw

std::optional<LockfileRaw> flox::resolver::Environment::lockfileRaw
private

New/modified lockfile being edited.

◆ manifest

EnvironmentManifest flox::resolver::Environment::manifest
private

The environment manifest.

◆ oldLockfile

std::optional<Lockfile> flox::resolver::Environment::oldLockfile
private

Previous generation of the lockfile ( if any ).

◆ upgrades

Upgrades flox::resolver::Environment::upgrades
private

Packages to force an upgrade for, even if they are already locked.


The documentation for this class was generated from the following files: