Skip to content

Commit 8f324fc

Browse files
committed
style(mcl/*.d): Format all .d files
1 parent 34283e8 commit 8f324fc

File tree

15 files changed

+611
-330
lines changed

15 files changed

+611
-330
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;
@@ -47,7 +47,8 @@ string[string] getProcInfo(string fileOrData, bool file = true)
4747
{
4848
string[string] r;
4949
foreach (line; file ? fileOrData.readText().split(
50-
"\n").map!(strip).array : fileOrData.split("\n").map!(strip).array)
50+
"\n").map!(strip).array
51+
: fileOrData.split("\n").map!(strip).array)
5152
{
5253
if (line.indexOf(":") == -1 || line.strip == "edid-decode (hex):")
5354
{
@@ -205,7 +206,7 @@ ProcessorInfo getProcessorInfo()
205206
r.vendor = cpuid.x86_any.vendor;
206207
char[48] modelCharArr;
207208
cpuid.x86_any.brand(modelCharArr);
208-
r.model = modelCharArr.idup[0..(strlen(modelCharArr.ptr)-1)];
209+
r.model = modelCharArr.idup[0 .. (strlen(modelCharArr.ptr) - 1)];
209210
r.cpus = cpuid.unified.cpus();
210211
r.cores = [r.cpus * cpuid.unified.cores()];
211212
r.threads = [cpuid.unified.threads()];
@@ -384,8 +385,15 @@ MemoryInfo getMemoryInfo()
384385
r.count = dmi.getFromDmi("Type:").length;
385386
r.slots = dmi.getFromDmi("Memory Device")
386387
.filter!(a => a.indexOf("DMI type 17") != -1).array.length;
387-
r.totalGB = dmi.getFromDmi("Size:").map!(a => a.split(" ")[0]).array.filter!(isNumeric).array.map!(to!int).array.sum();
388-
r.total =r.totalGB.to!string ~ " GB (" ~ dmi.getFromDmi("Size:").map!(a => a.split(" ")[0]).join("/") ~ ")";
388+
r.totalGB = dmi.getFromDmi("Size:").map!(a => a.split(" ")[0])
389+
.array
390+
.filter!(isNumeric)
391+
.array
392+
.map!(to!int)
393+
.array
394+
.sum();
395+
r.total = r.totalGB.to!string ~ " GB (" ~ dmi.getFromDmi("Size:")
396+
.map!(a => a.split(" ")[0]).join("/") ~ ")";
389397
auto totalWidth = dmi.getFromDmi("Total Width");
390398
auto dataWidth = dmi.getFromDmi("Data Width");
391399
foreach (i, width; totalWidth)
@@ -570,7 +578,8 @@ DisplayInfo getDisplayInfo()
570578
d.model = ("Model" in edidData) ? edidData["Model"] : "Unknown";
571579
d.serial = ("Serial Number" in edidData) ? edidData["Serial Number"] : "Unknown";
572580
d.manufactureDate = ("Made in" in edidData) ? edidData["Made in"] : "Unknown";
573-
d.size = ("Maximum image size" in edidData) ? edidData["Maximum image size"] : "Unknown";
581+
d.size = ("Maximum image size" in edidData) ? edidData["Maximum image size"]
582+
: "Unknown";
574583
}
575584

576585
r.displays ~= d;
@@ -596,11 +605,14 @@ struct GraphicsProcessorInfo
596605
GraphicsProcessorInfo getGraphicsProcessorInfo()
597606
{
598607
GraphicsProcessorInfo r;
599-
if ("DISPLAY" !in environment) return r;
600-
try {
608+
if ("DISPLAY" !in environment)
609+
return r;
610+
try
611+
{
601612
auto glxinfo = getProcInfo(execute("glxinfo", false), false);
602613
r.vendor = ("OpenGL vendor string" in glxinfo) ? glxinfo["OpenGL vendor string"] : "Unknown";
603-
r.model = ("OpenGL renderer string" in glxinfo) ? glxinfo["OpenGL renderer string"] : "Unknown";
614+
r.model = ("OpenGL renderer string" in glxinfo) ? glxinfo["OpenGL renderer string"]
615+
: "Unknown";
604616
r.coreProfile = ("OpenGL core profile version string" in glxinfo) ? glxinfo["OpenGL core profile version string"] : "Unknown";
605617
r.vram = ("Video memory" in glxinfo) ? glxinfo["Video memory"] : "Unknown";
606618
}
@@ -641,7 +653,6 @@ MachineConfigInfo getMachineConfigInfo()
641653
{
642654
MachineConfigInfo r;
643655

644-
645656
// PCI devices
646657
foreach (path; dirEntries("/sys/bus/pci/devices", SpanMode.shallow).map!(a => a.name).array)
647658
{
@@ -751,31 +762,38 @@ MachineConfigInfo getMachineConfigInfo()
751762
}
752763

753764
if (_module != "" &&
754-
// Mass-storage controller. Definitely important.
755-
_class.startsWith("0x08") ||
756-
// Keyboard. Needed if we want to use the keyboard when things go wrong in the initrd.
757-
(subClass.startsWith("0x03") || protocol.startsWith("0x01")))
765+
// Mass-storage controller. Definitely important.
766+
_class.startsWith("0x08") ||
767+
// Keyboard. Needed if we want to use the keyboard when things go wrong in the initrd.
768+
(subClass.startsWith("0x03") || protocol.startsWith("0x01")))
758769
{
759770
r.availableKernelModules ~= _module;
760771
}
761772
}
762773

763774
// Block and MMC devices
764775
foreach (path; (
765-
(exists("/sys/class/block") ? dirEntries("/sys/class/block", SpanMode.shallow).array : []) ~
766-
(exists("/sys/class/mmc_host") ? dirEntries("/sys/class/mmc_host", SpanMode.shallow).array : []))
776+
(exists("/sys/class/block") ? dirEntries("/sys/class/block", SpanMode.shallow)
777+
.array : []) ~
778+
(exists("/sys/class/mmc_host") ? dirEntries("/sys/class/mmc_host", SpanMode.shallow).array
779+
: []))
767780
.map!(a => a.name).array)
768781
{
769-
if (exists(path ~ "/device/driver/module")) {
782+
if (exists(path ~ "/device/driver/module"))
783+
{
770784
string _module = readLink(path ~ "/device/driver/module").baseName;
771785
r.availableKernelModules ~= _module;
772786
}
773787
}
774788
// Bcache
775-
auto bcacheDevices = dirEntries("/dev", SpanMode.shallow).map!(a => a.name).array.filter!(a => a.startsWith("bcache")).array;
789+
auto bcacheDevices = dirEntries("/dev", SpanMode.shallow).map!(a => a.name)
790+
.array
791+
.filter!(a => a.startsWith("bcache"))
792+
.array;
776793
bcacheDevices = bcacheDevices.filter!(device => device.indexOf("dev/bcachefs") == -1).array;
777794

778-
if (bcacheDevices.length > 0) {
795+
if (bcacheDevices.length > 0)
796+
{
779797
r.availableKernelModules ~= "bcache";
780798
}
781799
//Prevent unbootable systems if LVM snapshots are present at boot time.
@@ -785,27 +803,29 @@ MachineConfigInfo getMachineConfigInfo()
785803
}
786804
// Check if we're in a VirtualBox guest. If so, enable the guest additions.
787805
auto virt = execute!ProcessPipes("systemd-detect-virt", false).stdout.readln.strip;
788-
switch (virt) {
789-
case "oracle":
790-
r.literalAttrs ~= Literal("virtualisation.virtualbox.guest.enable = true;");
791-
break;
792-
case "parallels":
793-
r.literalAttrs ~= Literal("hardware.parallels.enable = true;");
794-
r.literalAttrs ~= Literal("nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ \"prl-tools\" ];");
795-
break;
796-
case "qemu":
797-
case "kvm":
798-
case "bochs":
799-
r.imports ~= Literal("(modulesPath + \"/profiles/qemu-guest.nix\")");
800-
break;
801-
case "microsoft":
802-
r.literalAttrs ~= Literal("virtualization.hypervGuest.enable = true;");
803-
break;
804-
case "systemd-nspawn":
805-
r.literalAttrs ~= Literal("boot.isContainer;");
806-
break;
807-
default:
808-
break;
806+
switch (virt)
807+
{
808+
case "oracle":
809+
r.literalAttrs ~= Literal("virtualisation.virtualbox.guest.enable = true;");
810+
break;
811+
case "parallels":
812+
r.literalAttrs ~= Literal("hardware.parallels.enable = true;");
813+
r.literalAttrs ~= Literal(
814+
"nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ \"prl-tools\" ];");
815+
break;
816+
case "qemu":
817+
case "kvm":
818+
case "bochs":
819+
r.imports ~= Literal("(modulesPath + \"/profiles/qemu-guest.nix\")");
820+
break;
821+
case "microsoft":
822+
r.literalAttrs ~= Literal("virtualization.hypervGuest.enable = true;");
823+
break;
824+
case "systemd-nspawn":
825+
r.literalAttrs ~= Literal("boot.isContainer;");
826+
break;
827+
default:
828+
break;
809829
}
810830

811831
return r;

0 commit comments

Comments
 (0)