Nix 2.26.3
Nix, the purely functional package manager; unstable internal interfaces
 
Loading...
Searching...
No Matches
nix::fetchers::Input Struct Reference

#include <fetchers.hh>

Public Member Functions

 Input (const Settings &settings)
 
ParsedURL toURL () const
 
std::string toURLString (const std::map< std::string, std::string > &extraQuery={}) const
 
std::string to_string () const
 
Attrs toAttrs () const
 
bool isDirect () const
 
bool isLocked () const
 
bool isConsideredLocked (const Settings &settings) const
 
std::optional< std::string > isRelative () const
 
bool isFinal () const
 
bool operator== (const Input &other) const noexcept
 
bool operator< (const Input &other) const
 
bool contains (const Input &other) const
 
std::pair< StorePath, InputfetchToStore (ref< Store > store) const
 
std::pair< ref< SourceAccessor >, InputgetAccessor (ref< Store > store) const
 
Input applyOverrides (std::optional< std::string > ref, std::optional< Hash > rev) const
 
void clone (const Path &destDir) const
 
std::optional< std::filesystem::path > getSourcePath () const
 
void putFile (const CanonPath &path, std::string_view contents, std::optional< std::string > commitMsg) const
 
std::string getName () const
 
StorePath computeStorePath (Store &store) const
 
std::string getType () const
 
std::optional< HashgetNarHash () const
 
std::optional< std::string > getRef () const
 
std::optional< HashgetRev () const
 
std::optional< uint64_t > getRevCount () const
 
std::optional< time_t > getLastModified () const
 
std::optional< std::string > getFingerprint (ref< Store > store) const
 

Static Public Member Functions

static Input fromURL (const Settings &settings, const std::string &url, bool requireTree=true)
 
static Input fromURL (const Settings &settings, const ParsedURL &url, bool requireTree=true)
 
static Input fromAttrs (const Settings &settings, Attrs &&attrs)
 
static void checkLocks (Input specified, Input &result)
 

Public Attributes

const Settingssettings
 
std::shared_ptr< InputSchemescheme
 
Attrs attrs
 
std::optional< std::optional< std::string > > cachedFingerprint
 

Friends

struct InputScheme
 

Detailed Description

The Input object is generated by a specific fetcher, based on user-supplied information, and contains the information that the specific fetcher needs to perform the actual fetch. The Input object is most commonly created via the fromURL() or fromAttrs() static functions.

Member Function Documentation

◆ checkLocks()

void nix::fetchers::Input::checkLocks ( Input specified,
Input & result )
static

Check the locking attributes in result against specified. E.g. if specified has a rev attribute, then result must have the same rev attribute. Throw an exception if there is a mismatch.

If specified is marked final (i.e. has the __final attribute), then the intersection of attributes in specified and result must be equal, and final.attrs is set to specified.attrs (i.e. we discard any new attributes).

◆ fetchToStore()

std::pair< StorePath, Input > nix::fetchers::Input::fetchToStore ( ref< Store > store) const

Fetch the entire input into the Nix store, returning the location in the Nix store and the locked input.

◆ fromAttrs()

Input nix::fetchers::Input::fromAttrs ( const Settings & settings,
Attrs && attrs )
static

Create an Input from a an Attrs.

The URL indicate which sort of fetcher, and provides information to that fetcher.

◆ fromURL()

Input nix::fetchers::Input::fromURL ( const Settings & settings,
const std::string & url,
bool requireTree = true )
static

Create an Input from a URL.

The URL indicate which sort of fetcher, and provides information to that fetcher.

◆ getAccessor()

std::pair< ref< SourceAccessor >, Input > nix::fetchers::Input::getAccessor ( ref< Store > store) const

Return a SourceAccessor that allows access to files in the input without copying it to the store. Also return a possibly unlocked input.

◆ getFingerprint()

std::optional< std::string > nix::fetchers::Input::getFingerprint ( ref< Store > store) const

For locked inputs, return a string that uniquely specifies the content of the input (typically a commit hash or content hash).

Only known-equivalent inputs should return the same fingerprint.

This is not a stable identifier between Nix versions, but not guaranteed to change either.

◆ isConsideredLocked()

bool nix::fetchers::Input::isConsideredLocked ( const Settings & settings) const

Return whether the input is either locked, or, if allow-dirty-locks is enabled, it has a NAR hash. In the latter case, we can verify the input but we may not be able to fetch it from anywhere.

◆ isDirect()

bool nix::fetchers::Input::isDirect ( ) const

Return whether this is a "direct" input, that is, not one that goes through a registry.

◆ isFinal()

bool nix::fetchers::Input::isFinal ( ) const

Return whether this is a "final" input, meaning that fetching it will not add, remove or change any attributes. (See checkLocks() for the semantics.) Only "final" inputs can be substituted from a binary cache.

The "final" state is denoted by the presence of an attribute __final = true. This attribute is currently undocumented and for internal use only.

◆ isLocked()

bool nix::fetchers::Input::isLocked ( ) const

Return whether this is a "locked" input, that is, it has attributes like a Git revision or NAR hash that uniquely identify its contents.

◆ isRelative()

std::optional< std::string > nix::fetchers::Input::isRelative ( ) const

Only for relative path flakes, i.e. 'path:./foo', returns the relative path, i.e. './foo'.

◆ putFile()

void nix::fetchers::Input::putFile ( const CanonPath & path,
std::string_view contents,
std::optional< std::string > commitMsg ) const

Write a file to this input, for input types that support writing. Optionally commit the change (for e.g. Git inputs).

Member Data Documentation

◆ cachedFingerprint

std::optional<std::optional<std::string> > nix::fetchers::Input::cachedFingerprint
mutable

Cached result of getFingerprint().


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