mirror of
https://github.com/NixOS/nix
synced 2025-07-07 01:51:47 +02:00
Merge branch 'master' into bundler_drv
This commit is contained in:
commit
2bf96bd9f2
44 changed files with 166 additions and 27171 deletions
|
@ -405,7 +405,7 @@ expr_select
|
|||
expr_simple
|
||||
: ID {
|
||||
std::string_view s = "__curPos";
|
||||
if (strncmp($1.p, s.data(), s.size()) == 0)
|
||||
if ($1.l == s.size() && strncmp($1.p, s.data(), s.size()) == 0)
|
||||
$$ = new ExprPos(CUR_POS);
|
||||
else
|
||||
$$ = new ExprVar(CUR_POS, data->symbols.create($1));
|
||||
|
|
|
@ -92,8 +92,6 @@ StringMap EvalState::realiseContext(const PathSet & context)
|
|||
}
|
||||
|
||||
struct RealisePathFlags {
|
||||
// Whether to check whether the path is a valid absolute path
|
||||
bool requireAbsolutePath = true;
|
||||
// Whether to check that the path is allowed in pure eval mode
|
||||
bool checkForPureEval = true;
|
||||
};
|
||||
|
@ -105,9 +103,7 @@ static Path realisePath(EvalState & state, const Pos & pos, Value & v, const Rea
|
|||
auto path = [&]()
|
||||
{
|
||||
try {
|
||||
return flags.requireAbsolutePath
|
||||
? state.coerceToPath(pos, v, context)
|
||||
: state.coerceToString(pos, v, context, false, false);
|
||||
return state.coerceToPath(pos, v, context);
|
||||
} catch (Error & e) {
|
||||
e.addTrace(pos, "while realising the context of a path");
|
||||
throw;
|
||||
|
@ -1183,7 +1179,7 @@ static void prim_derivationStrict(EvalState & state, const Pos & pos, Value * *
|
|||
drv.outputs.insert_or_assign(i, DerivationOutput {
|
||||
.output = DerivationOutputCAFloating {
|
||||
.method = ingestionMethod,
|
||||
.hashType = std::move(ht),
|
||||
.hashType = ht,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
@ -1489,7 +1485,19 @@ static void prim_findFile(EvalState & state, const Pos & pos, Value * * args, Va
|
|||
pos
|
||||
);
|
||||
|
||||
auto path = realisePath(state, pos, *i->value, { .requireAbsolutePath = false });
|
||||
PathSet context;
|
||||
string path = state.coerceToString(pos, *i->value, context, false, false);
|
||||
|
||||
try {
|
||||
auto rewrites = state.realiseContext(context);
|
||||
path = rewriteStrings(path, rewrites);
|
||||
} catch (InvalidPathError & e) {
|
||||
throw EvalError({
|
||||
.msg = hintfmt("cannot find '%1%', since path '%2%' is not valid", path, e.path),
|
||||
.errPos = pos
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
searchPath.emplace_back(prefix, path);
|
||||
}
|
||||
|
|
|
@ -981,7 +981,11 @@ void processConnection(
|
|||
readInt(from);
|
||||
}
|
||||
|
||||
readInt(from); // obsolete reserveSpace
|
||||
if (GET_PROTOCOL_MINOR(clientVersion) >= 11)
|
||||
readInt(from); // obsolete reserveSpace
|
||||
|
||||
if (GET_PROTOCOL_MINOR(clientVersion) >= 33)
|
||||
to << nixVersion;
|
||||
|
||||
/* Send startup error messages to the client. */
|
||||
tunnelLogger->startWork();
|
||||
|
|
|
@ -1919,4 +1919,10 @@ void LocalStore::addBuildLog(const StorePath & drvPath, std::string_view log)
|
|||
throw SysError("renaming '%1%' to '%2%'", tmpFile, logPath);
|
||||
}
|
||||
|
||||
std::optional<std::string> LocalStore::getVersion()
|
||||
{
|
||||
return nixVersion;
|
||||
}
|
||||
|
||||
|
||||
} // namespace nix
|
||||
|
|
|
@ -211,6 +211,8 @@ public:
|
|||
void queryRealisationUncached(const DrvOutput&,
|
||||
Callback<std::shared_ptr<const Realisation>> callback) noexcept override;
|
||||
|
||||
std::optional<std::string> getVersion() override;
|
||||
|
||||
private:
|
||||
|
||||
int getSchema();
|
||||
|
|
|
@ -188,7 +188,12 @@ void RemoteStore::initConnection(Connection & conn)
|
|||
}
|
||||
|
||||
if (GET_PROTOCOL_MINOR(conn.daemonVersion) >= 11)
|
||||
conn.to << false;
|
||||
conn.to << false; // obsolete reserveSpace
|
||||
|
||||
if (GET_PROTOCOL_MINOR(conn.daemonVersion) >= 33) {
|
||||
conn.to.flush();
|
||||
conn.daemonNixVersion = readString(conn.from);
|
||||
}
|
||||
|
||||
auto ex = conn.processStderr();
|
||||
if (ex) std::rethrow_exception(ex);
|
||||
|
@ -920,6 +925,13 @@ void RemoteStore::addBuildLog(const StorePath & drvPath, std::string_view log)
|
|||
}
|
||||
|
||||
|
||||
std::optional<std::string> RemoteStore::getVersion()
|
||||
{
|
||||
auto conn(getConnection());
|
||||
return conn->daemonNixVersion;
|
||||
}
|
||||
|
||||
|
||||
void RemoteStore::connect()
|
||||
{
|
||||
auto conn(getConnection());
|
||||
|
|
|
@ -118,6 +118,8 @@ public:
|
|||
|
||||
void addBuildLog(const StorePath & drvPath, std::string_view log) override;
|
||||
|
||||
std::optional<std::string> getVersion() override;
|
||||
|
||||
void connect() override;
|
||||
|
||||
unsigned int getProtocol() override;
|
||||
|
@ -129,6 +131,7 @@ public:
|
|||
FdSink to;
|
||||
FdSource from;
|
||||
unsigned int daemonVersion;
|
||||
std::optional<std::string> daemonNixVersion;
|
||||
std::chrono::time_point<std::chrono::steady_clock> startTime;
|
||||
|
||||
virtual ~Connection();
|
||||
|
|
|
@ -765,6 +765,9 @@ public:
|
|||
* (a no-op when there’s no daemon)
|
||||
*/
|
||||
virtual void setOptions() { }
|
||||
|
||||
virtual std::optional<std::string> getVersion() { return {}; }
|
||||
|
||||
protected:
|
||||
|
||||
Stats stats;
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace nix {
|
|||
#define WORKER_MAGIC_1 0x6e697863
|
||||
#define WORKER_MAGIC_2 0x6478696f
|
||||
|
||||
#define PROTOCOL_VERSION (1 << 8 | 32)
|
||||
#define PROTOCOL_VERSION (1 << 8 | 33)
|
||||
#define GET_PROTOCOL_MAJOR(x) ((x) & 0xff00)
|
||||
#define GET_PROTOCOL_MINOR(x) ((x) & 0x00ff)
|
||||
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
#if 0
|
||||
#include "logging.hh"
|
||||
#include "rust-ffi.hh"
|
||||
|
||||
extern "C" std::exception_ptr * make_error(rust::StringSlice s)
|
||||
{
|
||||
return new std::exception_ptr(std::make_exception_ptr(nix::Error(std::string(s.ptr, s.size))));
|
||||
}
|
||||
|
||||
extern "C" void destroy_error(std::exception_ptr * ex)
|
||||
{
|
||||
free(ex);
|
||||
}
|
||||
|
||||
namespace rust {
|
||||
|
||||
std::ostream & operator << (std::ostream & str, const String & s)
|
||||
{
|
||||
str << (std::string_view) s;
|
||||
return str;
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
|
@ -1,189 +0,0 @@
|
|||
#pragma once
|
||||
#if 0
|
||||
|
||||
#include "serialise.hh"
|
||||
|
||||
#include <string_view>
|
||||
#include <cstring>
|
||||
#include <array>
|
||||
|
||||
namespace rust {
|
||||
|
||||
typedef void (*DropFun)(void *);
|
||||
|
||||
/* A Rust value of N bytes. It can be moved but not copied. When it
|
||||
goes out of scope, the C++ destructor will run the drop
|
||||
function. */
|
||||
template<std::size_t N, DropFun drop>
|
||||
struct Value
|
||||
{
|
||||
protected:
|
||||
|
||||
std::array<char, N> raw;
|
||||
|
||||
~Value()
|
||||
{
|
||||
if (!isEvacuated()) {
|
||||
drop(this);
|
||||
evacuate();
|
||||
}
|
||||
}
|
||||
|
||||
// Must not be called directly.
|
||||
Value()
|
||||
{ }
|
||||
|
||||
Value(Value && other)
|
||||
: raw(other.raw)
|
||||
{
|
||||
other.evacuate();
|
||||
}
|
||||
|
||||
void operator =(Value && other)
|
||||
{
|
||||
if (!isEvacuated())
|
||||
drop(this);
|
||||
raw = other.raw;
|
||||
other.evacuate();
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
/* FIXME: optimize these (ideally in such a way that the compiler
|
||||
can elide most calls to evacuate() / isEvacuated(). */
|
||||
inline void evacuate()
|
||||
{
|
||||
for (auto & i : raw) i = 0;
|
||||
}
|
||||
|
||||
inline bool isEvacuated()
|
||||
{
|
||||
for (auto & i : raw)
|
||||
if (i != 0) return false;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
/* A Rust vector. */
|
||||
template<typename T, DropFun drop>
|
||||
struct Vec : Value<3 * sizeof(void *), drop>
|
||||
{
|
||||
inline size_t size() const
|
||||
{
|
||||
return ((const size_t *) &this->raw)[2];
|
||||
}
|
||||
|
||||
const T * data() const
|
||||
{
|
||||
return ((const T * *) &this->raw)[0];
|
||||
}
|
||||
};
|
||||
|
||||
/* A Rust slice. */
|
||||
template<typename T>
|
||||
struct Slice
|
||||
{
|
||||
const T * ptr;
|
||||
size_t size;
|
||||
|
||||
Slice(const T * ptr, size_t size) : ptr(ptr), size(size)
|
||||
{
|
||||
assert(ptr);
|
||||
}
|
||||
};
|
||||
|
||||
struct StringSlice : Slice<char>
|
||||
{
|
||||
StringSlice(const std::string & s): Slice(s.data(), s.size()) {}
|
||||
explicit StringSlice(std::string_view s): Slice(s.data(), s.size()) {}
|
||||
StringSlice(const char * s): Slice(s, strlen(s)) {}
|
||||
|
||||
operator std::string_view() const
|
||||
{
|
||||
return std::string_view(ptr, size);
|
||||
}
|
||||
};
|
||||
|
||||
/* A Rust string. */
|
||||
struct String;
|
||||
|
||||
extern "C" {
|
||||
void ffi_String_new(StringSlice s, String * out);
|
||||
void ffi_String_drop(void * s);
|
||||
}
|
||||
|
||||
struct String : Vec<char, ffi_String_drop>
|
||||
{
|
||||
String() = delete;
|
||||
|
||||
String(std::string_view s)
|
||||
{
|
||||
ffi_String_new(StringSlice(s), this);
|
||||
}
|
||||
|
||||
String(const char * s)
|
||||
: String({s, std::strlen(s)})
|
||||
{
|
||||
}
|
||||
|
||||
operator std::string_view() const
|
||||
{
|
||||
return std::string_view(data(), size());
|
||||
}
|
||||
};
|
||||
|
||||
std::ostream & operator << (std::ostream & str, const String & s);
|
||||
|
||||
/* C++ representation of Rust's Result<T, CppException>. */
|
||||
template<typename T>
|
||||
struct Result
|
||||
{
|
||||
enum { Ok = 0, Err = 1, Uninit = 2 } tag;
|
||||
|
||||
union {
|
||||
T data;
|
||||
std::exception_ptr * exc;
|
||||
};
|
||||
|
||||
Result() : tag(Uninit) { }; // FIXME: remove
|
||||
|
||||
Result(const Result &) = delete;
|
||||
|
||||
Result(Result && other)
|
||||
: tag(other.tag)
|
||||
{
|
||||
other.tag = Uninit;
|
||||
if (tag == Ok)
|
||||
data = std::move(other.data);
|
||||
else if (tag == Err)
|
||||
exc = other.exc;
|
||||
}
|
||||
|
||||
~Result()
|
||||
{
|
||||
if (tag == Ok)
|
||||
data.~T();
|
||||
else if (tag == Err)
|
||||
free(exc);
|
||||
else if (tag == Uninit)
|
||||
;
|
||||
else
|
||||
abort();
|
||||
}
|
||||
|
||||
/* Rethrow the wrapped exception or return the wrapped value. */
|
||||
T unwrap()
|
||||
{
|
||||
if (tag == Ok) {
|
||||
tag = Uninit;
|
||||
return std::move(data);
|
||||
}
|
||||
else if (tag == Err)
|
||||
std::rethrow_exception(*exc);
|
||||
else
|
||||
abort();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
#endif
|
|
@ -911,36 +911,45 @@ static void queryJSON(Globals & globals, vector<DrvInfo> & elems, bool printOutP
|
|||
{
|
||||
JSONObject topObj(cout, true);
|
||||
for (auto & i : elems) {
|
||||
JSONObject pkgObj = topObj.object(i.attrPath);
|
||||
try {
|
||||
if (i.hasFailed()) continue;
|
||||
|
||||
auto drvName = DrvName(i.queryName());
|
||||
pkgObj.attr("name", drvName.fullName);
|
||||
pkgObj.attr("pname", drvName.name);
|
||||
pkgObj.attr("version", drvName.version);
|
||||
pkgObj.attr("system", i.querySystem());
|
||||
JSONObject pkgObj = topObj.object(i.attrPath);
|
||||
|
||||
if (printOutPath) {
|
||||
DrvInfo::Outputs outputs = i.queryOutputs();
|
||||
JSONObject outputObj = pkgObj.object("outputs");
|
||||
for (auto & j : outputs) {
|
||||
outputObj.attr(j.first, j.second);
|
||||
}
|
||||
}
|
||||
auto drvName = DrvName(i.queryName());
|
||||
pkgObj.attr("name", drvName.fullName);
|
||||
pkgObj.attr("pname", drvName.name);
|
||||
pkgObj.attr("version", drvName.version);
|
||||
pkgObj.attr("system", i.querySystem());
|
||||
|
||||
if (printMeta) {
|
||||
JSONObject metaObj = pkgObj.object("meta");
|
||||
StringSet metaNames = i.queryMetaNames();
|
||||
for (auto & j : metaNames) {
|
||||
auto placeholder = metaObj.placeholder(j);
|
||||
Value * v = i.queryMeta(j);
|
||||
if (!v) {
|
||||
printError("derivation '%s' has invalid meta attribute '%s'", i.queryName(), j);
|
||||
placeholder.write(nullptr);
|
||||
} else {
|
||||
PathSet context;
|
||||
printValueAsJSON(*globals.state, true, *v, noPos, placeholder, context);
|
||||
if (printOutPath) {
|
||||
DrvInfo::Outputs outputs = i.queryOutputs();
|
||||
JSONObject outputObj = pkgObj.object("outputs");
|
||||
for (auto & j : outputs) {
|
||||
outputObj.attr(j.first, j.second);
|
||||
}
|
||||
}
|
||||
|
||||
if (printMeta) {
|
||||
JSONObject metaObj = pkgObj.object("meta");
|
||||
StringSet metaNames = i.queryMetaNames();
|
||||
for (auto & j : metaNames) {
|
||||
auto placeholder = metaObj.placeholder(j);
|
||||
Value * v = i.queryMeta(j);
|
||||
if (!v) {
|
||||
printError("derivation '%s' has invalid meta attribute '%s'", i.queryName(), j);
|
||||
placeholder.write(nullptr);
|
||||
} else {
|
||||
PathSet context;
|
||||
printValueAsJSON(*globals.state, true, *v, noPos, placeholder, context);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (AssertionError & e) {
|
||||
printMsg(lvlTalkative, "skipping derivation named '%1%' which gives an assertion failure", i.queryName());
|
||||
} catch (Error & e) {
|
||||
e.addTrace(std::nullopt, "while querying the derivation named '%1%'", i.queryName());
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,10 @@ struct CmdPingStore : StoreCommand
|
|||
|
||||
void run(ref<Store> store) override
|
||||
{
|
||||
notice("Store URL: %s", store->getUri());
|
||||
store->connect();
|
||||
if (auto version = store->getVersion())
|
||||
notice("Version: %s", *version);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
25447
src/nlohmann/json.hpp
25447
src/nlohmann/json.hpp
File diff suppressed because it is too large
Load diff
|
@ -1,78 +0,0 @@
|
|||
#ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_
|
||||
#define INCLUDE_NLOHMANN_JSON_FWD_HPP_
|
||||
|
||||
#include <cstdint> // int64_t, uint64_t
|
||||
#include <map> // map
|
||||
#include <memory> // allocator
|
||||
#include <string> // string
|
||||
#include <vector> // vector
|
||||
|
||||
/*!
|
||||
@brief namespace for Niels Lohmann
|
||||
@see https://github.com/nlohmann
|
||||
@since version 1.0.0
|
||||
*/
|
||||
namespace nlohmann
|
||||
{
|
||||
/*!
|
||||
@brief default JSONSerializer template argument
|
||||
|
||||
This serializer ignores the template arguments and uses ADL
|
||||
([argument-dependent lookup](https://en.cppreference.com/w/cpp/language/adl))
|
||||
for serialization.
|
||||
*/
|
||||
template<typename T = void, typename SFINAE = void>
|
||||
struct adl_serializer;
|
||||
|
||||
template<template<typename U, typename V, typename... Args> class ObjectType =
|
||||
std::map,
|
||||
template<typename U, typename... Args> class ArrayType = std::vector,
|
||||
class StringType = std::string, class BooleanType = bool,
|
||||
class NumberIntegerType = std::int64_t,
|
||||
class NumberUnsignedType = std::uint64_t,
|
||||
class NumberFloatType = double,
|
||||
template<typename U> class AllocatorType = std::allocator,
|
||||
template<typename T, typename SFINAE = void> class JSONSerializer =
|
||||
adl_serializer,
|
||||
class BinaryType = std::vector<std::uint8_t>>
|
||||
class basic_json;
|
||||
|
||||
/*!
|
||||
@brief JSON Pointer
|
||||
|
||||
A JSON pointer defines a string syntax for identifying a specific value
|
||||
within a JSON document. It can be used with functions `at` and
|
||||
`operator[]`. Furthermore, JSON pointers are the base for JSON patches.
|
||||
|
||||
@sa [RFC 6901](https://tools.ietf.org/html/rfc6901)
|
||||
|
||||
@since version 2.0.0
|
||||
*/
|
||||
template<typename BasicJsonType>
|
||||
class json_pointer;
|
||||
|
||||
/*!
|
||||
@brief default JSON class
|
||||
|
||||
This type is the default specialization of the @ref basic_json class which
|
||||
uses the standard template types.
|
||||
|
||||
@since version 1.0.0
|
||||
*/
|
||||
using json = basic_json<>;
|
||||
|
||||
template<class Key, class T, class IgnoredLess, class Allocator>
|
||||
struct ordered_map;
|
||||
|
||||
/*!
|
||||
@brief ordered JSON class
|
||||
|
||||
This type preserves the insertion order of object keys.
|
||||
|
||||
@since version 3.9.0
|
||||
*/
|
||||
using ordered_json = basic_json<nlohmann::ordered_map>;
|
||||
|
||||
} // namespace nlohmann
|
||||
|
||||
#endif // INCLUDE_NLOHMANN_JSON_FWD_HPP_
|
|
@ -1,2 +0,0 @@
|
|||
$(foreach i, $(wildcard src/nlohmann/*.hpp), \
|
||||
$(eval $(call install-file-in, $(i), $(includedir)/nlohmann, 0644)))
|
Loading…
Add table
Add a link
Reference in a new issue