oslib/server/src/main.zig

65 lines
2 KiB
Zig
Raw Normal View History

2024-06-24 12:54:49 -06:00
const std = @import("std");
2024-06-24 13:50:55 -06:00
const process = std.process;
const heap = std.heap;
const mem = std.mem;
2024-06-24 12:54:49 -06:00
const fs = std.fs;
const libvirt = @import("libvirt.zig");
pub fn main() !void {
2024-06-24 13:50:55 -06:00
var gpa = heap.GeneralPurposeAllocator(.{}){};
2024-06-24 12:54:49 -06:00
defer _ = gpa.deinit();
const allocator = gpa.allocator();
const connection = try libvirt.Connection.connect("qemu+ssh://jeeves@evil.lan/system", allocator);
defer connection.close();
2024-06-24 13:50:55 -06:00
var nix = process.Child.init(&[_][]const u8{ "nix", "build", ".#volume" }, allocator);
nix.cwd_dir = try fs.cwd().openDir("flakes/windows/test", .{});
_ = try nix.spawnAndWait();
2024-06-24 12:54:49 -06:00
2024-06-24 13:50:55 -06:00
// const uri = try connection.getURI();
// defer connection.freeURI(uri);
// std.debug.print("uri: {s}\n", .{uri});
2024-06-24 12:54:49 -06:00
2024-06-24 13:50:55 -06:00
// const num_active = try connection.numOfDomains();
// const num_inactive = try connection.numOfDefinedDomains();
// std.debug.print("active: {d}, inactive: {d}\n", .{ num_active, num_inactive });
2024-06-24 12:54:49 -06:00
2024-06-24 13:50:55 -06:00
// var domain_iter = connection.iterateDomains(&[_]libvirt.Domain.Flags{
// libvirt.Domain.Flags.ListDomainsActive,
// libvirt.Domain.Flags.ListDomainsInactive,
// });
// defer domain_iter.deinit();
2024-06-24 12:54:49 -06:00
2024-06-24 13:50:55 -06:00
// while (domain_iter.next()) |domain| {
// const active = domain.isActive();
// const name = domain.getName();
// std.debug.print("name: {s}, active: {any}\n", .{ name, active });
2024-06-24 12:54:49 -06:00
// }
// var flake = try fs.cwd().createFile("flake.nix", .{});
// defer flake.close();
// try flake.writeAll(
// \\{
// \\ description = "vm-flake";
// \\ inputs.oslib.url = "git+https://git.jeevio.xyz/jeeves/oslib";
// \\ outputs = { self, oslib }: oslib.vmFlake {
// \\
// \\ };
// \\}
// );
}
pub const DomainSpec = struct {
os: Quad,
preinstalledSoftware: []const []const u8,
modules: []const []const u8,
};
pub const Quad = struct {
name: []const u8,
version: []const u8,
edition: []const u8,
arch: []const u8,
};