Skip to content

Commit fa6c989

Browse files
committed
style(mcl/*.d): Format all .d files
1 parent a26a713 commit fa6c989

File tree

15 files changed

+609
-329
lines changed

15 files changed

+609
-329
lines changed

packages/mcl/src/main.d

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@ int main(string[] args)
5757
void setLogLevel(LogLevel l)
5858
{
5959
import std.logger : globalLogLevel, sharedLog;
60+
6061
globalLogLevel = l;
61-
(cast()sharedLog()).logLevel = l;
62+
(cast() sharedLog()).logLevel = l;
6263
}
6364

6465
int wrongUsage(string error)

packages/mcl/src/src/mcl/commands/ci.d

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
module mcl.commands.ci;
22

33
import std.file : readText;
4-
import std.json : parseJSON,JSONValue;
5-
import std.stdio : writeln,write;
4+
import std.json : parseJSON, JSONValue;
5+
import std.stdio : writeln, write;
66
import std.algorithm : map;
77
import std.array : array, join;
88
import std.conv : to;
@@ -38,17 +38,21 @@ export void ci()
3838
params.flakePost = "." ~ params.flakePost;
3939
}
4040
string cachixUrl = "https://" ~ params.cachixCache ~ ".cachix.org";
41-
version (AArch64) {
41+
version (AArch64)
42+
{
4243
string arch = "aarch64";
4344
}
44-
version (X86_64) {
45+
version (X86_64)
46+
{
4547
string arch = "x86_64";
4648
}
4749

48-
version (linux) {
50+
version (linux)
51+
{
4952
string os = "linux";
5053
}
51-
version (OSX) {
54+
version (OSX)
55+
{
5256
string os = "darwin";
5357
}
5458

@@ -64,7 +68,9 @@ export void ci()
6468
else
6569
{
6670
writeln("Package ", pkg.name, " is not cached; building...");
67-
ProcessPipes res = execute!ProcessPipes(["nix", "build", "--json", ".#" ~ pkg.attrPath]);
71+
ProcessPipes res = execute!ProcessPipes([
72+
"nix", "build", "--json", ".#" ~ pkg.attrPath
73+
]);
6874

6975
foreach (line; res.stderr.byLine)
7076
{

packages/mcl/src/src/mcl/commands/ci_matrix.d

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -175,13 +175,17 @@ Package[] checkCacheStatus(Package[] packages)
175175
foreach (ref pkg; packages.parallel)
176176
{
177177
pkg = checkPackage(pkg);
178-
struct Output { string isCached, name, storePath; }
178+
struct Output
179+
{
180+
string isCached, name, storePath;
181+
}
182+
179183
auto res = appender!string;
180184
writeRecordAsTable(
181185
Output(pkg.isCached ? "" : "", pkg.name, pkg.output),
182186
res
183187
);
184-
tracef("%s", res.data[0..$-1]);
188+
tracef("%s", res.data[0 .. $ - 1]);
185189
}
186190
return packages;
187191
}
@@ -462,10 +466,12 @@ unittest
462466

463467
void saveCachixDeploySpec(Package[] packages)
464468
{
465-
auto agents = packages.filter!(pkg => pkg.isCached == false).map!(pkg => JSONValue([
466-
"package": pkg.name,
467-
"out": pkg.output
468-
])).array;
469+
auto agents = packages.filter!(pkg => pkg.isCached == false)
470+
.map!(pkg => JSONValue([
471+
"package": pkg.name,
472+
"out": pkg.output
473+
]))
474+
.array;
469475
auto resPath = resultDir.buildPath("cachix-deploy-spec.json");
470476
resPath.write(JSONValue(agents).toString(JSONOptions.doNotEscapeSlashes));
471477
}
@@ -669,8 +675,9 @@ unittest
669675
const storePath = "/nix/store/" ~ storePathHash ~ "-hello-2.12.1";
670676

671677
auto testPackage = Package(
672-
output: storePath,
673-
cacheUrl: nixosCacheEndpoint ~ storePathHash ~ ".narinfo",
678+
output : storePath,
679+
cacheUrl:
680+
nixosCacheEndpoint ~ storePathHash ~ ".narinfo",
674681
);
675682

676683
assert(!testPackage.isCached);

packages/mcl/src/src/mcl/commands/host_info.d

Lines changed: 60 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import std.file : exists, write, readText, readLink, dirEntries, SpanMode;
1414
import std.path : baseName;
1515
import std.json;
1616
import std.process : ProcessPipes, environment;
17-
import core.stdc.string: strlen;
17+
import core.stdc.string : strlen;
1818

1919
import mcl.utils.env : parseEnv, optional;
2020
import mcl.utils.json : toJSON;
@@ -50,7 +50,8 @@ string[string] getProcInfo(string fileOrData, bool file = true)
5050
{
5151
string[string] r;
5252
foreach (line; file ? fileOrData.readText().split(
53-
"\n").map!(strip).array : fileOrData.split("\n").map!(strip).array)
53+
"\n").map!(strip).array
54+
: fileOrData.split("\n").map!(strip).array)
5455
{
5556
if (line.indexOf(":") == -1 || line.strip == "edid-decode (hex):")
5657
{
@@ -292,7 +293,7 @@ ProcessorInfo getProcessorInfo()
292293
r.vendor = cpuid.x86_any.vendor;
293294
char[48] modelCharArr;
294295
cpuid.x86_any.brand(modelCharArr);
295-
r.model = modelCharArr.idup[0..(strlen(modelCharArr.ptr)-1)];
296+
r.model = modelCharArr.idup[0 .. (strlen(modelCharArr.ptr) - 1)];
296297
r.cpus = cpuid.unified.cpus();
297298
r.cores = [r.cpus * cpuid.unified.cores()];
298299
r.threads = [cpuid.unified.threads()];
@@ -471,8 +472,15 @@ MemoryInfo getMemoryInfo()
471472
r.count = dmi.getFromDmi("Type:").length;
472473
r.slots = dmi.getFromDmi("Memory Device")
473474
.filter!(a => a.indexOf("DMI type 17") != -1).array.length;
474-
r.totalGB = dmi.getFromDmi("Size:").map!(a => a.split(" ")[0]).array.filter!(isNumeric).array.map!(to!int).array.sum();
475-
r.total =r.totalGB.to!string ~ " GB (" ~ dmi.getFromDmi("Size:").map!(a => a.split(" ")[0]).join("/") ~ ")";
475+
r.totalGB = dmi.getFromDmi("Size:").map!(a => a.split(" ")[0])
476+
.array
477+
.filter!(isNumeric)
478+
.array
479+
.map!(to!int)
480+
.array
481+
.sum();
482+
r.total = r.totalGB.to!string ~ " GB (" ~ dmi.getFromDmi("Size:")
483+
.map!(a => a.split(" ")[0]).join("/") ~ ")";
476484
auto totalWidth = dmi.getFromDmi("Total Width");
477485
auto dataWidth = dmi.getFromDmi("Data Width");
478486
foreach (i, width; totalWidth)
@@ -657,7 +665,8 @@ DisplayInfo getDisplayInfo()
657665
d.model = ("Model" in edidData) ? edidData["Model"] : "Unknown";
658666
d.serial = ("Serial Number" in edidData) ? edidData["Serial Number"] : "Unknown";
659667
d.manufactureDate = ("Made in" in edidData) ? edidData["Made in"] : "Unknown";
660-
d.size = ("Maximum image size" in edidData) ? edidData["Maximum image size"] : "Unknown";
668+
d.size = ("Maximum image size" in edidData) ? edidData["Maximum image size"]
669+
: "Unknown";
661670
}
662671

663672
r.displays ~= d;
@@ -683,11 +692,14 @@ struct GraphicsProcessorInfo
683692
GraphicsProcessorInfo getGraphicsProcessorInfo()
684693
{
685694
GraphicsProcessorInfo r;
686-
if ("DISPLAY" !in environment) return r;
687-
try {
695+
if ("DISPLAY" !in environment)
696+
return r;
697+
try
698+
{
688699
auto glxinfo = getProcInfo(execute("glxinfo", false), false);
689700
r.vendor = ("OpenGL vendor string" in glxinfo) ? glxinfo["OpenGL vendor string"] : "Unknown";
690-
r.model = ("OpenGL renderer string" in glxinfo) ? glxinfo["OpenGL renderer string"] : "Unknown";
701+
r.model = ("OpenGL renderer string" in glxinfo) ? glxinfo["OpenGL renderer string"]
702+
: "Unknown";
691703
r.coreProfile = ("OpenGL core profile version string" in glxinfo) ? glxinfo["OpenGL core profile version string"] : "Unknown";
692704
r.vram = ("Video memory" in glxinfo) ? glxinfo["Video memory"] : "Unknown";
693705
}
@@ -728,7 +740,6 @@ MachineConfigInfo getMachineConfigInfo()
728740
{
729741
MachineConfigInfo r;
730742

731-
732743
// PCI devices
733744
foreach (path; dirEntries("/sys/bus/pci/devices", SpanMode.shallow).map!(a => a.name).array)
734745
{
@@ -838,31 +849,38 @@ MachineConfigInfo getMachineConfigInfo()
838849
}
839850

840851
if (_module != "" &&
841-
// Mass-storage controller. Definitely important.
842-
_class.startsWith("0x08") ||
843-
// Keyboard. Needed if we want to use the keyboard when things go wrong in the initrd.
844-
(subClass.startsWith("0x03") || protocol.startsWith("0x01")))
852+
// Mass-storage controller. Definitely important.
853+
_class.startsWith("0x08") ||
854+
// Keyboard. Needed if we want to use the keyboard when things go wrong in the initrd.
855+
(subClass.startsWith("0x03") || protocol.startsWith("0x01")))
845856
{
846857
r.availableKernelModules ~= _module;
847858
}
848859
}
849860

850861
// Block and MMC devices
851862
foreach (path; (
852-
(exists("/sys/class/block") ? dirEntries("/sys/class/block", SpanMode.shallow).array : []) ~
853-
(exists("/sys/class/mmc_host") ? dirEntries("/sys/class/mmc_host", SpanMode.shallow).array : []))
863+
(exists("/sys/class/block") ? dirEntries("/sys/class/block", SpanMode.shallow)
864+
.array : []) ~
865+
(exists("/sys/class/mmc_host") ? dirEntries("/sys/class/mmc_host", SpanMode.shallow).array
866+
: []))
854867
.map!(a => a.name).array)
855868
{
856-
if (exists(path ~ "/device/driver/module")) {
869+
if (exists(path ~ "/device/driver/module"))
870+
{
857871
string _module = readLink(path ~ "/device/driver/module").baseName;
858872
r.availableKernelModules ~= _module;
859873
}
860874
}
861875
// Bcache
862-
auto bcacheDevices = dirEntries("/dev", SpanMode.shallow).map!(a => a.name).array.filter!(a => a.startsWith("bcache")).array;
876+
auto bcacheDevices = dirEntries("/dev", SpanMode.shallow).map!(a => a.name)
877+
.array
878+
.filter!(a => a.startsWith("bcache"))
879+
.array;
863880
bcacheDevices = bcacheDevices.filter!(device => device.indexOf("dev/bcachefs") == -1).array;
864881

865-
if (bcacheDevices.length > 0) {
882+
if (bcacheDevices.length > 0)
883+
{
866884
r.availableKernelModules ~= "bcache";
867885
}
868886
//Prevent unbootable systems if LVM snapshots are present at boot time.
@@ -872,27 +890,29 @@ MachineConfigInfo getMachineConfigInfo()
872890
}
873891
// Check if we're in a VirtualBox guest. If so, enable the guest additions.
874892
auto virt = execute!ProcessPipes("systemd-detect-virt", false).stdout.readln.strip;
875-
switch (virt) {
876-
case "oracle":
877-
r.literalAttrs ~= Literal("virtualisation.virtualbox.guest.enable = true;");
878-
break;
879-
case "parallels":
880-
r.literalAttrs ~= Literal("hardware.parallels.enable = true;");
881-
r.literalAttrs ~= Literal("nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ \"prl-tools\" ];");
882-
break;
883-
case "qemu":
884-
case "kvm":
885-
case "bochs":
886-
r.imports ~= Literal("(modulesPath + \"/profiles/qemu-guest.nix\")");
887-
break;
888-
case "microsoft":
889-
r.literalAttrs ~= Literal("virtualization.hypervGuest.enable = true;");
890-
break;
891-
case "systemd-nspawn":
892-
r.literalAttrs ~= Literal("boot.isContainer;");
893-
break;
894-
default:
895-
break;
893+
switch (virt)
894+
{
895+
case "oracle":
896+
r.literalAttrs ~= Literal("virtualisation.virtualbox.guest.enable = true;");
897+
break;
898+
case "parallels":
899+
r.literalAttrs ~= Literal("hardware.parallels.enable = true;");
900+
r.literalAttrs ~= Literal(
901+
"nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ \"prl-tools\" ];");
902+
break;
903+
case "qemu":
904+
case "kvm":
905+
case "bochs":
906+
r.imports ~= Literal("(modulesPath + \"/profiles/qemu-guest.nix\")");
907+
break;
908+
case "microsoft":
909+
r.literalAttrs ~= Literal("virtualization.hypervGuest.enable = true;");
910+
break;
911+
case "systemd-nspawn":
912+
r.literalAttrs ~= Literal("boot.isContainer;");
913+
break;
914+
default:
915+
break;
896916
}
897917

898918
return r;

0 commit comments

Comments
 (0)