Skip to content

Commit cc52333

Browse files
PetarKirovmonyarm
authored andcommitted
feat(mcl.commands.deploy_spec): Implement createMachineDeploySpec and use it
1 parent c21d014 commit cc52333

File tree

1 file changed

+34
-4
lines changed

1 file changed

+34
-4
lines changed

packages/mcl/src/src/mcl/commands/deploy_spec.d

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,50 @@ import std.path : buildPath;
66

77
import mcl.utils.process : spawnProcessInline;
88
import mcl.utils.path : resultDir;
9+
import mcl.utils.env : parseEnv;
910

10-
import mcl.commands.ci_matrix : ci_matrix;
11+
import mcl.commands.ci_matrix : ci_matrix, Params, nixEvalJobs, SupportedSystem;
1112

12-
export void deploy_spec()
13+
shared string deploySpecFile;
14+
15+
shared static this()
1316
{
14-
auto deploySpecFile = resultDir.buildPath("cachix-deploy-spec.json");
17+
deploySpecFile = resultDir.buildPath("cachix-deploy-spec.json");
18+
}
1519

20+
export void deploy_spec()
21+
{
1622
if (!deploySpecFile.exists)
1723
{
1824
warningf("'%s' file not found - building...", deploySpecFile);
19-
ci_matrix();
25+
createMachineDeploySpec();
2026
}
2127

2228
spawnProcessInline([
2329
"cachix", "deploy", "activate", deploySpecFile
2430
]);
2531
}
32+
33+
void createMachineDeploySpec()
34+
{
35+
import std.algorithm : map;
36+
import std.array : assocArray;
37+
import std.json : JSONValue;
38+
import std.typecons : tuple;
39+
import std.file : writeFile = write;
40+
41+
auto params = parseEnv!Params;
42+
params.flakePre = "legacyPackages";
43+
params.flakePost = ".bareMetalMachines";
44+
45+
string cachixUrl = "https://" ~ params.cachixCache ~ ".cachix.org";
46+
auto packages = nixEvalJobs(params, SupportedSystem.x86_64_linux, cachixUrl);
47+
48+
auto result = [
49+
"agents": packages
50+
.map!(pkg => tuple(pkg.name, pkg.output))
51+
.assocArray
52+
].JSONValue;
53+
54+
writeFile(deploySpecFile, result.toString());
55+
}

0 commit comments

Comments
 (0)