mirror of
https://github.com/NixOS/nix.git
synced 2025-11-21 17:59:36 +01:00
Expose the nix component in header include paths
For example, instead of doing
#include "nix/store-config.hh"
#include "nix/derived-path.hh"
Now do
#include "nix/store/config.hh"
#include "nix/store/derived-path.hh"
This was originally planned in the issue, and also recent requested by
Eelco.
Most of the change is purely mechanical. There is just one small
additional issue. See how, in the example above, we took this
opportunity to also turn `<comp>-config.hh` into `<comp>/config.hh`.
Well, there was already a `nix/util/config.{cc,hh}`. Even though there
is not a public configuration header for libutil (which also would be
called `nix/util/config.{cc,hh}`) that's still confusing, To avoid any
such confusion, we renamed that to `nix/util/configuration.{cc,hh}`.
Finally, note that the libflake headers already did this, so we didn't
need to do anything to them. We wouldn't want to mistakenly get
`nix/flake/flake/flake.hh`!
Progress on #7876
(cherry picked from commit cc24766fa6)
This commit is contained in:
parent
64fb6ab435
commit
0c67777396
645 changed files with 2562 additions and 2562 deletions
85
src/libexpr/include/nix/expr/value/context.hh
Normal file
85
src/libexpr/include/nix/expr/value/context.hh
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
#pragma once
|
||||
///@file
|
||||
|
||||
#include "nix/util/comparator.hh"
|
||||
#include "nix/store/derived-path.hh"
|
||||
#include "nix/util/variant-wrapper.hh"
|
||||
|
||||
#include <nlohmann/json_fwd.hpp>
|
||||
|
||||
namespace nix {
|
||||
|
||||
class BadNixStringContextElem : public Error
|
||||
{
|
||||
public:
|
||||
std::string_view raw;
|
||||
|
||||
template<typename... Args>
|
||||
BadNixStringContextElem(std::string_view raw_, const Args & ... args)
|
||||
: Error("")
|
||||
{
|
||||
raw = raw_;
|
||||
auto hf = HintFmt(args...);
|
||||
err.msg = HintFmt("Bad String Context element: %1%: %2%", Uncolored(hf.str()), raw);
|
||||
}
|
||||
};
|
||||
|
||||
struct NixStringContextElem {
|
||||
/**
|
||||
* Plain opaque path to some store object.
|
||||
*
|
||||
* Encoded as just the path: `<path>`.
|
||||
*/
|
||||
using Opaque = SingleDerivedPath::Opaque;
|
||||
|
||||
/**
|
||||
* Path to a derivation and its entire build closure.
|
||||
*
|
||||
* The path doesn't just refer to derivation itself and its closure, but
|
||||
* also all outputs of all derivations in that closure (including the
|
||||
* root derivation).
|
||||
*
|
||||
* Encoded in the form `=<drvPath>`.
|
||||
*/
|
||||
struct DrvDeep {
|
||||
StorePath drvPath;
|
||||
|
||||
GENERATE_CMP(DrvDeep, me->drvPath);
|
||||
};
|
||||
|
||||
/**
|
||||
* Derivation output.
|
||||
*
|
||||
* Encoded in the form `!<output>!<drvPath>`.
|
||||
*/
|
||||
using Built = SingleDerivedPath::Built;
|
||||
|
||||
using Raw = std::variant<
|
||||
Opaque,
|
||||
DrvDeep,
|
||||
Built
|
||||
>;
|
||||
|
||||
Raw raw;
|
||||
|
||||
GENERATE_CMP(NixStringContextElem, me->raw);
|
||||
|
||||
MAKE_WRAPPER_CONSTRUCTOR(NixStringContextElem);
|
||||
|
||||
/**
|
||||
* Decode a context string, one of:
|
||||
* - `<path>`
|
||||
* - `=<path>`
|
||||
* - `!<name>!<path>`
|
||||
*
|
||||
* @param xpSettings Stop-gap to avoid globals during unit tests.
|
||||
*/
|
||||
static NixStringContextElem parse(
|
||||
std::string_view s,
|
||||
const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings);
|
||||
std::string to_string() const;
|
||||
};
|
||||
|
||||
typedef std::set<NixStringContextElem> NixStringContext;
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue