Skip to content

Commit 60f9489

Browse files
authored
Merge pull request #14370 from NixOS/misc-cleanups
Miscellaneous cleanups
2 parents 6417863 + 91cd425 commit 60f9489

File tree

10 files changed

+21
-16
lines changed

10 files changed

+21
-16
lines changed

src/libexpr-tests/value/print.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ using namespace testing;
1010
struct ValuePrintingTests : LibExprTest
1111
{
1212
template<class... A>
13-
void test(Value v, std::string_view expected, A... args)
13+
void test(Value & v, std::string_view expected, A... args)
1414
{
1515
std::stringstream out;
1616
v.print(state, out, args...);
@@ -625,10 +625,11 @@ TEST_F(ValuePrintingTests, ansiColorsAttrsElided)
625625
vThree.mkInt(3);
626626

627627
builder.insert(state.symbols.create("three"), &vThree);
628-
vAttrs.mkAttrs(builder.finish());
628+
Value vAttrs2;
629+
vAttrs2.mkAttrs(builder.finish());
629630

630631
test(
631-
vAttrs,
632+
vAttrs2,
632633
"{ one = " ANSI_CYAN "1" ANSI_NORMAL "; " ANSI_FAINT "«2 attributes elided»" ANSI_NORMAL " }",
633634
PrintOptions{.ansiColors = true, .maxAttrs = 1});
634635
}

src/libstore/daemon.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1031,7 +1031,7 @@ void processConnection(ref<Store> store, FdSource && from, FdSink && to, Trusted
10311031
auto [protoVersion, features] =
10321032
WorkerProto::BasicServerConnection::handshake(to, from, PROTOCOL_VERSION, WorkerProto::allFeatures);
10331033

1034-
if (protoVersion < 256 + 18)
1034+
if (protoVersion < MINIMUM_PROTOCOL_VERSION)
10351035
throw Error("the Nix client version is too old");
10361036

10371037
WorkerProto::BasicServerConnection conn;

src/libstore/dummy-store.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ struct DummyStoreImpl : DummyStore
148148
/**
149149
* The dummy store is incapable of *not* trusting! :)
150150
*/
151-
virtual std::optional<TrustedFlag> isTrustedClient() override
151+
std::optional<TrustedFlag> isTrustedClient() override
152152
{
153153
return Trusted;
154154
}

src/libstore/filetransfer.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ struct curlFileTransfer : public FileTransfer
622622
void quit()
623623
{
624624
quitting = true;
625-
/* We wil not be processing any more incomming requests */
625+
/* We wil not be processing any more incoming requests */
626626
while (!incoming.empty())
627627
incoming.pop();
628628
}

src/libstore/globals.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ std::vector<Path> getUserConfigFiles()
150150
return files;
151151
}
152152

153-
unsigned int Settings::getDefaultCores() const
153+
unsigned int Settings::getDefaultCores()
154154
{
155155
const unsigned int concurrency = std::max(1U, std::thread::hardware_concurrency());
156156
const unsigned int maxCPU = getMaxCPU();

src/libstore/include/nix/store/globals.hh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public:
7777

7878
Settings();
7979

80-
unsigned int getDefaultCores() const;
80+
static unsigned int getDefaultCores();
8181

8282
Path nixPrefix;
8383

@@ -427,7 +427,7 @@ public:
427427
R"(
428428
If set to `true`, Nix instructs [remote build machines](#conf-builders) to use their own [`substituters`](#conf-substituters) if available.
429429
430-
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.
430+
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.
431431
This can drastically reduce build times if the network connection between the local machine and the remote build host is slow.
432432
)"};
433433

@@ -503,7 +503,7 @@ public:
503503
by the Nix account, its group should be the group specified here,
504504
and its mode should be `1775`.
505505
506-
If the build users group is empty, builds areperformed under
506+
If the build users group is empty, builds are performed under
507507
the uid of the Nix process (that is, the uid of the caller if
508508
`NIX_REMOTE` is empty, the uid under which the Nix daemon runs if
509509
`NIX_REMOTE` is `daemon`). Obviously, this should not be used
@@ -847,8 +847,8 @@ public:
847847
4. The path to the build's scratch directory. This directory
848848
exists only if the build was run with `--keep-failed`.
849849
850-
The stderr and stdout output from the diff hook isn't
851-
displayed to the user. Instead, it print to the nix-daemon's log.
850+
The stderr and stdout output from the diff hook isn't displayed
851+
to the user. Instead, it prints to the nix-daemon's log.
852852
853853
When using the Nix daemon, `diff-hook` must be set in the `nix.conf`
854854
configuration file, and cannot be passed at the command line.

src/libstore/include/nix/store/worker-protocol.hh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ namespace nix {
1313
/* Note: you generally shouldn't change the protocol version. Define a
1414
new `WorkerProto::Feature` instead. */
1515
#define PROTOCOL_VERSION (1 << 8 | 38)
16+
#define MINIMUM_PROTOCOL_VERSION (1 << 8 | 18)
1617
#define GET_PROTOCOL_MAJOR(x) ((x) & 0xff00)
1718
#define GET_PROTOCOL_MINOR(x) ((x) & 0x00ff)
1819

@@ -152,6 +153,7 @@ enum struct WorkerProto::Op : uint64_t {
152153
AddIndirectRoot = 12,
153154
SyncWithGC = 13,
154155
FindRoots = 14,
156+
// ExportPath = 16, // removed
155157
QueryDeriver = 18, // obsolete
156158
SetOptions = 19,
157159
CollectGarbage = 20,
@@ -161,6 +163,7 @@ enum struct WorkerProto::Op : uint64_t {
161163
QueryFailedPaths = 24,
162164
ClearFailedPaths = 25,
163165
QueryPathInfo = 26,
166+
// ImportPaths = 27, // removed
164167
QueryDerivationOutputNames = 28, // obsolete
165168
QueryPathFromHashPart = 29,
166169
QuerySubstitutablePathInfos = 30,

src/libstore/remote-store.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ void RemoteStore::initConnection(Connection & conn)
7373
try {
7474
auto [protoVersion, features] =
7575
WorkerProto::BasicClientConnection::handshake(conn.to, tee, PROTOCOL_VERSION, WorkerProto::allFeatures);
76-
if (protoVersion < 256 + 18)
76+
if (protoVersion < MINIMUM_PROTOCOL_VERSION)
7777
throw Error("the Nix daemon version is too old");
7878
conn.protoVersion = protoVersion;
7979
conn.features = features;

src/nix/env.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
#include <unordered_set>
21
#include <queue>
32

3+
#include <boost/unordered/unordered_flat_set.hpp>
4+
45
#include "nix/cmd/command.hh"
56
#include "nix/expr/eval.hh"
67
#include "run.hh"

src/nix/main.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,8 @@ static void showHelp(std::vector<std::string> subcommand, NixArgs & toplevel)
256256
vDump->mkString(toplevel.dumpCli());
257257

258258
auto vRes = state.allocValue();
259-
state.callFunction(*vGenerateManpage, state.getBuiltin("false"), *vRes, noPos);
260-
state.callFunction(*vRes, *vDump, *vRes, noPos);
259+
Value * args[]{&state.getBuiltin("false"), vDump};
260+
state.callFunction(*vGenerateManpage, args, *vRes, noPos);
261261

262262
auto attr = vRes->attrs()->get(state.symbols.create(mdName + ".md"));
263263
if (!attr)

0 commit comments

Comments
 (0)