Skip to content

Commit 3a67caf

Browse files
committed
Merge branch 'master' (reformat)
2 parents 72e8f7c + b8d223a commit 3a67caf

File tree

592 files changed

+23294
-23623
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

592 files changed

+23294
-23623
lines changed

.clang-format

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ BraceWrapping:
88
AfterUnion: true
99
SplitEmptyRecord: false
1010
PointerAlignment: Middle
11-
FixNamespaceComments: false
11+
FixNamespaceComments: true
1212
SortIncludes: Never
1313
#IndentPPDirectives: BeforeHash
1414
SpaceAfterCStyleCast: true
@@ -32,3 +32,4 @@ IndentPPDirectives: AfterHash
3232
PPIndentWidth: 2
3333
BinPackArguments: false
3434
BreakBeforeTernaryOperators: true
35+
SeparateDefinitionBlocks: Always

.git-blame-ignore-revs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# bulk initial re-formatting with clang-format
2+
e4f62e46088919428a68bd8014201dc8e379fed7 # !autorebase ./maintainers/format.sh --until-stable

maintainers/flake-module.nix

Lines changed: 0 additions & 461 deletions
Large diffs are not rendered by default.

maintainers/format.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
#!/usr/bin/env bash
22

33
if ! type -p pre-commit &>/dev/null; then
4-
echo "format.sh: pre-commit not found. Please use \`nix develop\`.";
4+
echo "format.sh: pre-commit not found. Please use \`nix develop -c ./maintainers/format.sh\`.";
55
exit 1;
66
fi;
77
if test -z "$_NIX_PRE_COMMIT_HOOKS_CONFIG"; then
8-
echo "format.sh: _NIX_PRE_COMMIT_HOOKS_CONFIG not set. Please use \`nix develop\`.";
8+
echo "format.sh: _NIX_PRE_COMMIT_HOOKS_CONFIG not set. Please use \`nix develop -c ./maintainers/format.sh\`.";
99
exit 1;
1010
fi;
11-
pre-commit run --config "$_NIX_PRE_COMMIT_HOOKS_CONFIG" --all-files
11+
12+
while ! pre-commit run --config "$_NIX_PRE_COMMIT_HOOKS_CONFIG" --all-files; do
13+
if [ "${1:-}" != "--until-stable" ]; then
14+
exit 1
15+
fi
16+
done

packaging/dev-shell.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ pkgs.nixComponents2.nix-util.overrideAttrs (
113113
) pkgs.buildPackages.mesonEmulatorHook
114114
++ [
115115
pkgs.buildPackages.cmake
116+
pkgs.buildPackages.gnused
116117
pkgs.buildPackages.shellcheck
117118
pkgs.buildPackages.changelog-d
118119
modular.pre-commit.settings.package

src/build-remote/build-remote.cc

Lines changed: 37 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <tuple>
77
#include <iomanip>
88
#ifdef __APPLE__
9-
#include <sys/time.h>
9+
# include <sys/time.h>
1010
#endif
1111

1212
#include "nix/store/machines.hh"
@@ -26,8 +26,7 @@
2626
using namespace nix;
2727
using std::cin;
2828

29-
static void handleAlarm(int sig) {
30-
}
29+
static void handleAlarm(int sig) {}
3130

3231
std::string escapeUri(std::string uri)
3332
{
@@ -42,13 +41,15 @@ static AutoCloseFD openSlotLock(const Machine & m, uint64_t slot)
4241
return openLockFile(fmt("%s/%s-%d", currentLoad, escapeUri(m.storeUri.render()), slot), true);
4342
}
4443

45-
static bool allSupportedLocally(Store & store, const StringSet& requiredFeatures) {
44+
static bool allSupportedLocally(Store & store, const StringSet & requiredFeatures)
45+
{
4646
for (auto & feature : requiredFeatures)
47-
if (!store.config.systemFeatures.get().count(feature)) return false;
47+
if (!store.config.systemFeatures.get().count(feature))
48+
return false;
4849
return true;
4950
}
5051

51-
static int main_build_remote(int argc, char * * argv)
52+
static int main_build_remote(int argc, char ** argv)
5253
{
5354
{
5455
logger = makeJSONLogger(getStandardError());
@@ -85,7 +86,7 @@ static int main_build_remote(int argc, char * * argv)
8586
that gets cleared on reboot, but it wouldn't work on macOS. */
8687
auto currentLoadName = "/current-load";
8788
if (auto localStore = store.dynamic_pointer_cast<LocalFSStore>())
88-
currentLoad = std::string { localStore->config.stateDir } + currentLoadName;
89+
currentLoad = std::string{localStore->config.stateDir} + currentLoadName;
8990
else
9091
currentLoad = settings.nixStateDir + currentLoadName;
9192

@@ -107,8 +108,11 @@ static int main_build_remote(int argc, char * * argv)
107108

108109
try {
109110
auto s = readString(source);
110-
if (s != "try") return 0;
111-
} catch (EndOfFile &) { return 0; }
111+
if (s != "try")
112+
return 0;
113+
} catch (EndOfFile &) {
114+
return 0;
115+
}
112116

113117
auto amWilling = readInt(source);
114118
auto neededSystem = readString(source);
@@ -117,10 +121,10 @@ static int main_build_remote(int argc, char * * argv)
117121

118122
/* It would be possible to build locally after some builds clear out,
119123
so don't show the warning now: */
120-
bool couldBuildLocally = maxBuildJobs > 0
121-
&& ( neededSystem == settings.thisSystem
122-
|| settings.extraPlatforms.get().count(neededSystem) > 0)
123-
&& allSupportedLocally(*store, requiredFeatures);
124+
bool couldBuildLocally =
125+
maxBuildJobs > 0
126+
&& (neededSystem == settings.thisSystem || settings.extraPlatforms.get().count(neededSystem) > 0)
127+
&& allSupportedLocally(*store, requiredFeatures);
124128
/* It's possible to build this locally right now: */
125129
bool canBuildLocally = amWilling && couldBuildLocally;
126130

@@ -139,11 +143,8 @@ static int main_build_remote(int argc, char * * argv)
139143
for (auto & m : machines) {
140144
debug("considering building on remote machine '%s'", m.storeUri.render());
141145

142-
if (m.enabled &&
143-
m.systemSupported(neededSystem) &&
144-
m.allSupported(requiredFeatures) &&
145-
m.mandatoryMet(requiredFeatures))
146-
{
146+
if (m.enabled && m.systemSupported(neededSystem) && m.allSupported(requiredFeatures)
147+
&& m.mandatoryMet(requiredFeatures)) {
147148
rightType = true;
148149
AutoCloseFD free;
149150
uint64_t load = 0;
@@ -185,8 +186,7 @@ static int main_build_remote(int argc, char * * argv)
185186
if (!bestSlotLock) {
186187
if (rightType && !canBuildLocally)
187188
std::cerr << "# postpone\n";
188-
else
189-
{
189+
else {
190190
// build the hint template.
191191
std::string errorText =
192192
"Failed to find a machine for remote build!\n"
@@ -205,16 +205,11 @@ static int main_build_remote(int argc, char * * argv)
205205
drvstr = "<unknown>";
206206

207207
auto error = HintFmt::fromFormatString(errorText);
208-
error
209-
% drvstr
210-
% neededSystem
211-
% concatStringsSep<StringSet>(", ", requiredFeatures)
208+
error % drvstr % neededSystem % concatStringsSep<StringSet>(", ", requiredFeatures)
212209
% machines.size();
213210

214211
for (auto & m : machines)
215-
error
216-
% concatStringsSep<StringSet>(", ", m.systemTypes)
217-
% m.maxJobs
212+
error % concatStringsSep<StringSet>(", ", m.systemTypes) % m.maxJobs
218213
% concatStringsSep<StringSet>(", ", m.supportedFeatures)
219214
% concatStringsSep<StringSet>(", ", m.mandatoryFeatures);
220215

@@ -242,9 +237,7 @@ static int main_build_remote(int argc, char * * argv)
242237
sshStore->connect();
243238
} catch (std::exception & e) {
244239
auto msg = chomp(drainFD(5, false));
245-
printError("cannot build on '%s': %s%s",
246-
storeUri, e.what(),
247-
msg.empty() ? "" : ": " + msg);
240+
printError("cannot build on '%s': %s%s", storeUri, e.what(), msg.empty() ? "" : ": " + msg);
248241
bestMachine->enabled = false;
249242
continue;
250243
}
@@ -253,7 +246,7 @@ static int main_build_remote(int argc, char * * argv)
253246
}
254247
}
255248

256-
connected:
249+
connected:
257250
close(5);
258251

259252
assert(sshStore);
@@ -265,13 +258,14 @@ static int main_build_remote(int argc, char * * argv)
265258

266259
AutoCloseFD uploadLock;
267260
{
268-
auto setUpdateLock = [&](auto && fileName){
261+
auto setUpdateLock = [&](auto && fileName) {
269262
uploadLock = openLockFile(currentLoad + "/" + escapeUri(fileName) + ".upload-lock", true);
270263
};
271264
try {
272265
setUpdateLock(storeUri);
273266
} catch (SysError & e) {
274-
if (e.errNo != ENAMETOOLONG) throw;
267+
if (e.errNo != ENAMETOOLONG)
268+
throw;
275269
// Try again hashing the store URL so we have a shorter path
276270
auto h = hashString(HashAlgorithm::MD5, storeUri);
277271
setUpdateLock(h.to_string(HashFormat::Base64, false));
@@ -315,7 +309,7 @@ static int main_build_remote(int argc, char * * argv)
315309
//
316310
// This condition mirrors that: that code enforces the "rules" outlined there;
317311
// we do the best we can given those "rules".
318-
if (trustedOrLegacy || drv.type().isCA()) {
312+
if (trustedOrLegacy || drv.type().isCA()) {
319313
// Hijack the inputs paths of the derivation to include all
320314
// the paths that come from the `inputDrvs` set. We don’t do
321315
// that for the derivations whose `inputDrvs` is empty
@@ -335,32 +329,29 @@ static int main_build_remote(int argc, char * * argv)
335329
"The failed build directory was kept on the remote builder due to `--keep-failed`.%s",
336330
(settings.thisSystem == drv.platform || settings.extraPlatforms.get().count(drv.platform) > 0)
337331
? " You can re-run the command with `--builders ''` to disable remote building for this invocation."
338-
: ""
339-
);
332+
: "");
340333
}
341-
throw Error("build of '%s' on '%s' failed: %s", store->printStorePath(*drvPath), storeUri, result.errorMsg);
334+
throw Error(
335+
"build of '%s' on '%s' failed: %s", store->printStorePath(*drvPath), storeUri, result.errorMsg);
342336
}
343337
} else {
344-
copyClosure(*store, *sshStore, StorePathSet {*drvPath}, NoRepair, NoCheckSigs, substitute);
345-
auto res = sshStore->buildPathsWithResults({
346-
DerivedPath::Built {
347-
.drvPath = makeConstantStorePathRef(*drvPath),
348-
.outputs = OutputsSpec::All {},
349-
}
350-
});
338+
copyClosure(*store, *sshStore, StorePathSet{*drvPath}, NoRepair, NoCheckSigs, substitute);
339+
auto res = sshStore->buildPathsWithResults({DerivedPath::Built{
340+
.drvPath = makeConstantStorePathRef(*drvPath),
341+
.outputs = OutputsSpec::All{},
342+
}});
351343
// One path to build should produce exactly one build result
352344
assert(res.size() == 1);
353345
optResult = std::move(res[0]);
354346
}
355347

356-
357348
auto outputHashes = staticOutputHashes(*store, drv);
358349
std::set<Realisation> missingRealisations;
359350
StorePathSet missingPaths;
360351
if (experimentalFeatureSettings.isEnabled(Xp::CaDerivations) && !drv.type().hasKnownOutputPaths()) {
361352
for (auto & outputName : wantedOutputs) {
362353
auto thisOutputHash = outputHashes.at(outputName);
363-
auto thisOutputId = DrvOutput{ thisOutputHash, outputName };
354+
auto thisOutputId = DrvOutput{thisOutputHash, outputName};
364355
if (!store->queryRealisation(thisOutputId)) {
365356
debug("missing output %s", outputName);
366357
assert(optResult);

src/libcmd/built-path.cc

Lines changed: 22 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,22 @@
1010
namespace nix {
1111

1212
// Custom implementation to avoid `ref` ptr equality
13-
GENERATE_CMP_EXT(
14-
,
15-
std::strong_ordering,
16-
SingleBuiltPathBuilt,
17-
*me->drvPath,
18-
me->output);
13+
GENERATE_CMP_EXT(, std::strong_ordering, SingleBuiltPathBuilt, *me->drvPath, me->output);
1914

2015
// Custom implementation to avoid `ref` ptr equality
2116

2217
// TODO no `GENERATE_CMP_EXT` because no `std::set::operator<=>` on
2318
// Darwin, per header.
24-
GENERATE_EQUAL(
25-
,
26-
BuiltPathBuilt ::,
27-
BuiltPathBuilt,
28-
*me->drvPath,
29-
me->outputs);
19+
GENERATE_EQUAL(, BuiltPathBuilt ::, BuiltPathBuilt, *me->drvPath, me->outputs);
3020

3121
StorePath SingleBuiltPath::outPath() const
3222
{
3323
return std::visit(
3424
overloaded{
3525
[](const SingleBuiltPath::Opaque & p) { return p.path; },
3626
[](const SingleBuiltPath::Built & b) { return b.output.second; },
37-
}, raw()
38-
);
27+
},
28+
raw());
3929
}
4030

4131
StorePathSet BuiltPath::outPaths() const
@@ -49,13 +39,13 @@ StorePathSet BuiltPath::outPaths() const
4939
res.insert(path);
5040
return res;
5141
},
52-
}, raw()
53-
);
42+
},
43+
raw());
5444
}
5545

5646
SingleDerivedPath::Built SingleBuiltPath::Built::discardOutputPath() const
5747
{
58-
return SingleDerivedPath::Built {
48+
return SingleDerivedPath::Built{
5949
.drvPath = make_ref<SingleDerivedPath>(drvPath->discardOutputPath()),
6050
.output = output.first,
6151
};
@@ -65,14 +55,10 @@ SingleDerivedPath SingleBuiltPath::discardOutputPath() const
6555
{
6656
return std::visit(
6757
overloaded{
68-
[](const SingleBuiltPath::Opaque & p) -> SingleDerivedPath {
69-
return p;
70-
},
71-
[](const SingleBuiltPath::Built & b) -> SingleDerivedPath {
72-
return b.discardOutputPath();
73-
},
74-
}, raw()
75-
);
58+
[](const SingleBuiltPath::Opaque & p) -> SingleDerivedPath { return p; },
59+
[](const SingleBuiltPath::Built & b) -> SingleDerivedPath { return b.discardOutputPath(); },
60+
},
61+
raw());
7662
}
7763

7864
nlohmann::json BuiltPath::Built::toJSON(const StoreDirConfig & store) const
@@ -97,16 +83,12 @@ nlohmann::json SingleBuiltPath::Built::toJSON(const StoreDirConfig & store) cons
9783

9884
nlohmann::json SingleBuiltPath::toJSON(const StoreDirConfig & store) const
9985
{
100-
return std::visit([&](const auto & buildable) {
101-
return buildable.toJSON(store);
102-
}, raw());
86+
return std::visit([&](const auto & buildable) { return buildable.toJSON(store); }, raw());
10387
}
10488

10589
nlohmann::json BuiltPath::toJSON(const StoreDirConfig & store) const
10690
{
107-
return std::visit([&](const auto & buildable) {
108-
return buildable.toJSON(store);
109-
}, raw());
91+
return std::visit([&](const auto & buildable) { return buildable.toJSON(store); }, raw());
11092
}
11193

11294
RealisedPath::Set BuiltPath::toRealisedPaths(Store & store) const
@@ -116,20 +98,18 @@ RealisedPath::Set BuiltPath::toRealisedPaths(Store & store) const
11698
overloaded{
11799
[&](const BuiltPath::Opaque & p) { res.insert(p.path); },
118100
[&](const BuiltPath::Built & p) {
119-
auto drvHashes =
120-
staticOutputHashes(store, store.readDerivation(p.drvPath->outPath()));
121-
for (auto& [outputName, outputPath] : p.outputs) {
122-
if (experimentalFeatureSettings.isEnabled(
123-
Xp::CaDerivations)) {
101+
auto drvHashes = staticOutputHashes(store, store.readDerivation(p.drvPath->outPath()));
102+
for (auto & [outputName, outputPath] : p.outputs) {
103+
if (experimentalFeatureSettings.isEnabled(Xp::CaDerivations)) {
124104
auto drvOutput = get(drvHashes, outputName);
125105
if (!drvOutput)
126106
throw Error(
127107
"the derivation '%s' has unrealised output '%s' (derived-path.cc/toRealisedPaths)",
128-
store.printStorePath(p.drvPath->outPath()), outputName);
129-
auto thisRealisation = store.queryRealisation(
130-
DrvOutput{*drvOutput, outputName});
131-
assert(thisRealisation); // We’ve built it, so we must
132-
// have the realisation
108+
store.printStorePath(p.drvPath->outPath()),
109+
outputName);
110+
auto thisRealisation = store.queryRealisation(DrvOutput{*drvOutput, outputName});
111+
assert(thisRealisation); // We’ve built it, so we must
112+
// have the realisation
133113
res.insert(*thisRealisation);
134114
} else {
135115
res.insert(outputPath);
@@ -141,4 +121,4 @@ RealisedPath::Set BuiltPath::toRealisedPaths(Store & store) const
141121
return res;
142122
}
143123

144-
}
124+
} // namespace nix

src/libcmd/command-installable-value.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ void InstallableValueCommand::run(ref<Store> store, ref<Installable> installable
88
run(store, installableValue);
99
}
1010

11-
}
11+
} // namespace nix

src/libcmd/command.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,4 +402,4 @@ void MixOutLinkBase::createOutLinksMaybe(const std::vector<BuiltPathWithResult>
402402
createOutLinks(outLink, toBuiltPaths(buildables), *store2);
403403
}
404404

405-
}
405+
} // namespace nix

0 commit comments

Comments
 (0)