mirror of
https://github.com/NixOS/nix.git
synced 2025-11-09 03:56:01 +01:00
Merge pull request #14370 from NixOS/misc-cleanups
Miscellaneous cleanups
This commit is contained in:
commit
60f9489b83
10 changed files with 21 additions and 16 deletions
|
|
@ -10,7 +10,7 @@ using namespace testing;
|
||||||
struct ValuePrintingTests : LibExprTest
|
struct ValuePrintingTests : LibExprTest
|
||||||
{
|
{
|
||||||
template<class... A>
|
template<class... A>
|
||||||
void test(Value v, std::string_view expected, A... args)
|
void test(Value & v, std::string_view expected, A... args)
|
||||||
{
|
{
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
v.print(state, out, args...);
|
v.print(state, out, args...);
|
||||||
|
|
@ -625,10 +625,11 @@ TEST_F(ValuePrintingTests, ansiColorsAttrsElided)
|
||||||
vThree.mkInt(3);
|
vThree.mkInt(3);
|
||||||
|
|
||||||
builder.insert(state.symbols.create("three"), &vThree);
|
builder.insert(state.symbols.create("three"), &vThree);
|
||||||
vAttrs.mkAttrs(builder.finish());
|
Value vAttrs2;
|
||||||
|
vAttrs2.mkAttrs(builder.finish());
|
||||||
|
|
||||||
test(
|
test(
|
||||||
vAttrs,
|
vAttrs2,
|
||||||
"{ one = " ANSI_CYAN "1" ANSI_NORMAL "; " ANSI_FAINT "«2 attributes elided»" ANSI_NORMAL " }",
|
"{ one = " ANSI_CYAN "1" ANSI_NORMAL "; " ANSI_FAINT "«2 attributes elided»" ANSI_NORMAL " }",
|
||||||
PrintOptions{.ansiColors = true, .maxAttrs = 1});
|
PrintOptions{.ansiColors = true, .maxAttrs = 1});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1031,7 +1031,7 @@ void processConnection(ref<Store> store, FdSource && from, FdSink && to, Trusted
|
||||||
auto [protoVersion, features] =
|
auto [protoVersion, features] =
|
||||||
WorkerProto::BasicServerConnection::handshake(to, from, PROTOCOL_VERSION, WorkerProto::allFeatures);
|
WorkerProto::BasicServerConnection::handshake(to, from, PROTOCOL_VERSION, WorkerProto::allFeatures);
|
||||||
|
|
||||||
if (protoVersion < 256 + 18)
|
if (protoVersion < MINIMUM_PROTOCOL_VERSION)
|
||||||
throw Error("the Nix client version is too old");
|
throw Error("the Nix client version is too old");
|
||||||
|
|
||||||
WorkerProto::BasicServerConnection conn;
|
WorkerProto::BasicServerConnection conn;
|
||||||
|
|
|
||||||
|
|
@ -148,7 +148,7 @@ struct DummyStoreImpl : DummyStore
|
||||||
/**
|
/**
|
||||||
* The dummy store is incapable of *not* trusting! :)
|
* The dummy store is incapable of *not* trusting! :)
|
||||||
*/
|
*/
|
||||||
virtual std::optional<TrustedFlag> isTrustedClient() override
|
std::optional<TrustedFlag> isTrustedClient() override
|
||||||
{
|
{
|
||||||
return Trusted;
|
return Trusted;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -622,7 +622,7 @@ struct curlFileTransfer : public FileTransfer
|
||||||
void quit()
|
void quit()
|
||||||
{
|
{
|
||||||
quitting = true;
|
quitting = true;
|
||||||
/* We wil not be processing any more incomming requests */
|
/* We wil not be processing any more incoming requests */
|
||||||
while (!incoming.empty())
|
while (!incoming.empty())
|
||||||
incoming.pop();
|
incoming.pop();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -150,7 +150,7 @@ std::vector<Path> getUserConfigFiles()
|
||||||
return files;
|
return files;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int Settings::getDefaultCores() const
|
unsigned int Settings::getDefaultCores()
|
||||||
{
|
{
|
||||||
const unsigned int concurrency = std::max(1U, std::thread::hardware_concurrency());
|
const unsigned int concurrency = std::max(1U, std::thread::hardware_concurrency());
|
||||||
const unsigned int maxCPU = getMaxCPU();
|
const unsigned int maxCPU = getMaxCPU();
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ public:
|
||||||
|
|
||||||
Settings();
|
Settings();
|
||||||
|
|
||||||
unsigned int getDefaultCores() const;
|
static unsigned int getDefaultCores();
|
||||||
|
|
||||||
Path nixPrefix;
|
Path nixPrefix;
|
||||||
|
|
||||||
|
|
@ -427,7 +427,7 @@ public:
|
||||||
R"(
|
R"(
|
||||||
If set to `true`, Nix instructs [remote build machines](#conf-builders) to use their own [`substituters`](#conf-substituters) if available.
|
If set to `true`, Nix instructs [remote build machines](#conf-builders) to use their own [`substituters`](#conf-substituters) if available.
|
||||||
|
|
||||||
It means that remote build hosts fetches as many dependencies as possible from their own substituters (e.g, from `cache.nixos.org`) instead of waiting for the local machine to upload them all.
|
It means that remote build hosts fetch as many dependencies as possible from their own substituters (e.g, from `cache.nixos.org`) instead of waiting for the local machine to upload them all.
|
||||||
This can drastically reduce build times if the network connection between the local machine and the remote build host is slow.
|
This can drastically reduce build times if the network connection between the local machine and the remote build host is slow.
|
||||||
)"};
|
)"};
|
||||||
|
|
||||||
|
|
@ -847,8 +847,8 @@ public:
|
||||||
4. The path to the build's scratch directory. This directory
|
4. The path to the build's scratch directory. This directory
|
||||||
exists only if the build was run with `--keep-failed`.
|
exists only if the build was run with `--keep-failed`.
|
||||||
|
|
||||||
The stderr and stdout output from the diff hook isn't
|
The stderr and stdout output from the diff hook isn't displayed
|
||||||
displayed to the user. Instead, it print to the nix-daemon's log.
|
to the user. Instead, it prints to the nix-daemon's log.
|
||||||
|
|
||||||
When using the Nix daemon, `diff-hook` must be set in the `nix.conf`
|
When using the Nix daemon, `diff-hook` must be set in the `nix.conf`
|
||||||
configuration file, and cannot be passed at the command line.
|
configuration file, and cannot be passed at the command line.
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ namespace nix {
|
||||||
/* Note: you generally shouldn't change the protocol version. Define a
|
/* Note: you generally shouldn't change the protocol version. Define a
|
||||||
new `WorkerProto::Feature` instead. */
|
new `WorkerProto::Feature` instead. */
|
||||||
#define PROTOCOL_VERSION (1 << 8 | 38)
|
#define PROTOCOL_VERSION (1 << 8 | 38)
|
||||||
|
#define MINIMUM_PROTOCOL_VERSION (1 << 8 | 18)
|
||||||
#define GET_PROTOCOL_MAJOR(x) ((x) & 0xff00)
|
#define GET_PROTOCOL_MAJOR(x) ((x) & 0xff00)
|
||||||
#define GET_PROTOCOL_MINOR(x) ((x) & 0x00ff)
|
#define GET_PROTOCOL_MINOR(x) ((x) & 0x00ff)
|
||||||
|
|
||||||
|
|
@ -152,6 +153,7 @@ enum struct WorkerProto::Op : uint64_t {
|
||||||
AddIndirectRoot = 12,
|
AddIndirectRoot = 12,
|
||||||
SyncWithGC = 13,
|
SyncWithGC = 13,
|
||||||
FindRoots = 14,
|
FindRoots = 14,
|
||||||
|
// ExportPath = 16, // removed
|
||||||
QueryDeriver = 18, // obsolete
|
QueryDeriver = 18, // obsolete
|
||||||
SetOptions = 19,
|
SetOptions = 19,
|
||||||
CollectGarbage = 20,
|
CollectGarbage = 20,
|
||||||
|
|
@ -161,6 +163,7 @@ enum struct WorkerProto::Op : uint64_t {
|
||||||
QueryFailedPaths = 24,
|
QueryFailedPaths = 24,
|
||||||
ClearFailedPaths = 25,
|
ClearFailedPaths = 25,
|
||||||
QueryPathInfo = 26,
|
QueryPathInfo = 26,
|
||||||
|
// ImportPaths = 27, // removed
|
||||||
QueryDerivationOutputNames = 28, // obsolete
|
QueryDerivationOutputNames = 28, // obsolete
|
||||||
QueryPathFromHashPart = 29,
|
QueryPathFromHashPart = 29,
|
||||||
QuerySubstitutablePathInfos = 30,
|
QuerySubstitutablePathInfos = 30,
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ void RemoteStore::initConnection(Connection & conn)
|
||||||
try {
|
try {
|
||||||
auto [protoVersion, features] =
|
auto [protoVersion, features] =
|
||||||
WorkerProto::BasicClientConnection::handshake(conn.to, tee, PROTOCOL_VERSION, WorkerProto::allFeatures);
|
WorkerProto::BasicClientConnection::handshake(conn.to, tee, PROTOCOL_VERSION, WorkerProto::allFeatures);
|
||||||
if (protoVersion < 256 + 18)
|
if (protoVersion < MINIMUM_PROTOCOL_VERSION)
|
||||||
throw Error("the Nix daemon version is too old");
|
throw Error("the Nix daemon version is too old");
|
||||||
conn.protoVersion = protoVersion;
|
conn.protoVersion = protoVersion;
|
||||||
conn.features = features;
|
conn.features = features;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#include <unordered_set>
|
|
||||||
#include <queue>
|
#include <queue>
|
||||||
|
|
||||||
|
#include <boost/unordered/unordered_flat_set.hpp>
|
||||||
|
|
||||||
#include "nix/cmd/command.hh"
|
#include "nix/cmd/command.hh"
|
||||||
#include "nix/expr/eval.hh"
|
#include "nix/expr/eval.hh"
|
||||||
#include "run.hh"
|
#include "run.hh"
|
||||||
|
|
|
||||||
|
|
@ -256,8 +256,8 @@ static void showHelp(std::vector<std::string> subcommand, NixArgs & toplevel)
|
||||||
vDump->mkString(toplevel.dumpCli());
|
vDump->mkString(toplevel.dumpCli());
|
||||||
|
|
||||||
auto vRes = state.allocValue();
|
auto vRes = state.allocValue();
|
||||||
state.callFunction(*vGenerateManpage, state.getBuiltin("false"), *vRes, noPos);
|
Value * args[]{&state.getBuiltin("false"), vDump};
|
||||||
state.callFunction(*vRes, *vDump, *vRes, noPos);
|
state.callFunction(*vGenerateManpage, args, *vRes, noPos);
|
||||||
|
|
||||||
auto attr = vRes->attrs()->get(state.symbols.create(mdName + ".md"));
|
auto attr = vRes->attrs()->get(state.symbols.create(mdName + ".md"));
|
||||||
if (!attr)
|
if (!attr)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue