This cleans up includes that clangd reports as unused, usually by deleting the offending include. The process was to delete an include and see if it still builds. If not, try to find a more specific include(s) that works, that was previously transitively included. If the original include seems intended to re-export said transitive include, mark the transitive include as `// IWYU pragma: export`. Otherwise, replace the original include with the transitive include(s). If none of the above applies, because the original file depends on code directly in the include somehow, or the direct include is an external dependency that cannot be modified, restore the original include and mark it as `// IWYU pragma: keep`. Change-Id: I5ce3d34dad76b0cad0a6a7990fea13add393aad3
93 lines
2.8 KiB
C++
93 lines
2.8 KiB
C++
#pragma once
|
|
///@file
|
|
|
|
#include "lix/libutil/types.hh"
|
|
#include "lix/libfetchers/fetchers.hh"
|
|
#include "lix/libstore/outputs-spec.hh"
|
|
|
|
namespace nix {
|
|
|
|
class Store;
|
|
|
|
typedef std::string FlakeId;
|
|
|
|
/**
|
|
* A flake reference specifies how to fetch a flake or raw source
|
|
* (e.g. from a Git repository). It is created from a URL-like syntax
|
|
* (e.g. 'github:NixOS/patchelf'), an attrset representation (e.g. '{
|
|
* type="github"; owner = "NixOS"; repo = "patchelf"; }'), or a local
|
|
* path.
|
|
*
|
|
* Each flake will have a number of FlakeRef objects: one for each
|
|
* input to the flake.
|
|
*
|
|
* The normal method of constructing a FlakeRef is by starting with an
|
|
* input description (usually the attrs or a url from the flake file),
|
|
* locating a fetcher for that input, and then capturing the Input
|
|
* object that fetcher generates (usually via
|
|
* FlakeRef::fromAttrs(attrs) or parseFlakeRef(url) calls).
|
|
*
|
|
* The actual fetch may not have been performed yet (i.e. a FlakeRef may
|
|
* be lazy), but the fetcher can be invoked at any time via the
|
|
* FlakeRef to ensure the store is populated with this input.
|
|
*/
|
|
struct FlakeRef
|
|
{
|
|
/**
|
|
* Fetcher-specific representation of the input, sufficient to
|
|
* perform the fetch operation.
|
|
*/
|
|
fetchers::Input input;
|
|
|
|
/**
|
|
* sub-path within the fetched input that represents this input
|
|
*/
|
|
Path subdir;
|
|
|
|
bool operator==(const FlakeRef & other) const;
|
|
|
|
FlakeRef(fetchers::Input && input, const Path & subdir)
|
|
: input(std::move(input)), subdir(subdir)
|
|
{ }
|
|
|
|
// FIXME: change to operator <<.
|
|
std::string to_string() const;
|
|
|
|
fetchers::Attrs toAttrs() const;
|
|
|
|
kj::Promise<Result<FlakeRef>> resolve(ref<Store> store) const;
|
|
|
|
static FlakeRef fromAttrs(const fetchers::Attrs & attrs);
|
|
|
|
kj::Promise<Result<std::pair<fetchers::Tree, FlakeRef>>> fetchTree(ref<Store> store) const;
|
|
};
|
|
|
|
std::ostream & operator << (std::ostream & str, const FlakeRef & flakeRef);
|
|
|
|
FlakeRef parseFlakeRef(
|
|
const std::string & url,
|
|
const std::optional<Path> & baseDir = {},
|
|
bool allowMissing = false,
|
|
bool isFlake = true);
|
|
|
|
std::optional<FlakeRef> maybeParseFlake(
|
|
const std::string & url, const std::optional<Path> & baseDir = {});
|
|
|
|
std::pair<FlakeRef, std::string> parseFlakeRefWithFragment(
|
|
const std::string & url,
|
|
const std::optional<Path> & baseDir = {},
|
|
bool allowMissing = false,
|
|
bool isFlake = true);
|
|
|
|
std::optional<std::pair<FlakeRef, std::string>> maybeParseFlakeRefWithFragment(
|
|
const std::string & url, const std::optional<Path> & baseDir = {});
|
|
|
|
std::tuple<FlakeRef, std::string, ExtendedOutputsSpec> parseFlakeRefWithFragmentAndExtendedOutputsSpec(
|
|
const std::string & url,
|
|
const std::optional<Path> & baseDir = {},
|
|
bool allowMissing = false,
|
|
bool isFlake = true);
|
|
|
|
|
|
}
|