make mkFlake at root of flake
This commit is contained in:
parent
8a816b5e85
commit
1531a79212
5 changed files with 276 additions and 126 deletions
199
server/flakes/windows/test/flake.lock
generated
Normal file
199
server/flakes/windows/test/flake.lock
generated
Normal file
|
@ -0,0 +1,199 @@
|
|||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1710146030,
|
||||
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_2": {
|
||||
"inputs": {
|
||||
"systems": "systems_2"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1710146030,
|
||||
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1719075281,
|
||||
"narHash": "sha256-CyyxvOwFf12I91PBWz43iGT1kjsf5oi6ax7CrvaMyAo=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "a71e967ef3694799d0c418c98332f7ff4cc5f6af",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs-ovmf": {
|
||||
"locked": {
|
||||
"lastModified": 1708984720,
|
||||
"narHash": "sha256-gJctErLbXx4QZBBbGp78PxtOOzsDaQ+yw1ylNQBuSUY=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "13aff9b34cc32e59d35c62ac9356e4a41198a538",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1708979614,
|
||||
"narHash": "sha256-FWLWmYojIg6TeqxSnHkKpHu5SGnFP5um1uUjH+wRV6g=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "b7ee09cf5614b02d289cd86fcfa6f24d4e078c2a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-23.11",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_3": {
|
||||
"locked": {
|
||||
"lastModified": 1718622336,
|
||||
"narHash": "sha256-lywfxWRBn+lwdKaBy5x5uTkbCcEPUonCn6bK8OQPsw4=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "d0fc4188d246ab953653f00e9ce0cf51d10d5eda",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixvirt": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs_2",
|
||||
"nixpkgs-ovmf": "nixpkgs-ovmf"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1718920754,
|
||||
"narHash": "sha256-y6OX0hGvqijTQRZ7Jiyt+WCWi/+oQdq6xwjhUtOk494=",
|
||||
"owner": "Nomkid",
|
||||
"repo": "NixVirt",
|
||||
"rev": "bf98e0864c15138361d9d9f2b5aee3d8889a0cd4",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "Nomkid",
|
||||
"repo": "NixVirt",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"oslib": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"nixvirt": "nixvirt",
|
||||
"zig2nix": "zig2nix"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1719255289,
|
||||
"narHash": "sha256-nHOAk/Dn6SHt7QW3tnQjm7ZE3kqO6w1n2Ht5bL9shoc=",
|
||||
"ref": "refs/heads/master",
|
||||
"rev": "8a816b5e852e621db6dba62b46d6f9dd25760e09",
|
||||
"revCount": 1,
|
||||
"type": "git",
|
||||
"url": "https://git.jeevio.xyz/jeeves/oslib"
|
||||
},
|
||||
"original": {
|
||||
"type": "git",
|
||||
"url": "https://git.jeevio.xyz/jeeves/oslib"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"oslib": "oslib"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems_2": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"zig2nix": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils_2",
|
||||
"nixpkgs": "nixpkgs_3"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1719192015,
|
||||
"narHash": "sha256-6hrQt6y+P0qV/VkJQ4n4bZSaZLJNYXrKecS6B1xb9Wk=",
|
||||
"owner": "Cloudef",
|
||||
"repo": "zig2nix",
|
||||
"rev": "048bebf58984486cf45c5e4119f4b149f27d7f1f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "Cloudef",
|
||||
"repo": "zig2nix",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
20
server/flakes/windows/test/flake.nix
Normal file
20
server/flakes/windows/test/flake.nix
Normal file
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
description = "windows test vm";
|
||||
inputs.oslib.url = "git+https://git.jeevio.xyz/jeeves/oslib";
|
||||
outputs = { self, oslib }: oslib.mkFlake {
|
||||
name = "wintest";
|
||||
uuid = "b691936e-1772-4b11-9dab-43b2a794ef90";
|
||||
os.name = "windows";
|
||||
os.version = "6.1.7601"; # 7 - Service Pack 1
|
||||
os.edition = "professional";
|
||||
os.arch = "x86_64";
|
||||
# preinstalledSoftware = with oslib.software.windows [
|
||||
# firefox
|
||||
# acrobat
|
||||
# msoffice_2007
|
||||
# ];
|
||||
# modules = with oslib.modules.windows [
|
||||
# scatterUserFiles { desktop = true; documents = true; }
|
||||
# ];
|
||||
};
|
||||
}
|
|
@ -1,61 +1,40 @@
|
|||
const std = @import("std");
|
||||
const process = std.process;
|
||||
const heap = std.heap;
|
||||
const mem = std.mem;
|
||||
const fs = std.fs;
|
||||
const libvirt = @import("libvirt.zig");
|
||||
|
||||
pub fn main() !void {
|
||||
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
|
||||
var gpa = heap.GeneralPurposeAllocator(.{}){};
|
||||
defer _ = gpa.deinit();
|
||||
const allocator = gpa.allocator();
|
||||
|
||||
// std.debug.print("{any}\n", .{libvirt.c.virConnectAuthPtr});
|
||||
|
||||
const connection = try libvirt.Connection.connect("qemu+ssh://jeeves@evil.lan/system", allocator);
|
||||
defer connection.close();
|
||||
|
||||
const uri = try connection.getURI();
|
||||
defer connection.freeURI(uri);
|
||||
std.debug.print("uri: {s}\n", .{uri});
|
||||
var nix = process.Child.init(&[_][]const u8{ "nix", "build", ".#volume" }, allocator);
|
||||
nix.cwd_dir = try fs.cwd().openDir("flakes/windows/test", .{});
|
||||
_ = try nix.spawnAndWait();
|
||||
|
||||
const num_active = try connection.numOfDomains();
|
||||
const num_inactive = try connection.numOfDefinedDomains();
|
||||
std.debug.print("active: {d}, inactive: {d}\n", .{ num_active, num_inactive });
|
||||
// const uri = try connection.getURI();
|
||||
// defer connection.freeURI(uri);
|
||||
// std.debug.print("uri: {s}\n", .{uri});
|
||||
|
||||
var domain_iter = connection.iterateDomains(&[_]libvirt.Domain.Flags{
|
||||
libvirt.Domain.Flags.ListDomainsActive,
|
||||
libvirt.Domain.Flags.ListDomainsInactive,
|
||||
});
|
||||
defer domain_iter.deinit();
|
||||
// const num_active = try connection.numOfDomains();
|
||||
// const num_inactive = try connection.numOfDefinedDomains();
|
||||
// std.debug.print("active: {d}, inactive: {d}\n", .{ num_active, num_inactive });
|
||||
|
||||
while (domain_iter.next()) |domain| {
|
||||
const active = domain.isActive();
|
||||
const name = domain.getName();
|
||||
std.debug.print("name: {s}, active: {any}\n", .{ name, active });
|
||||
}
|
||||
// var domain_iter = connection.iterateDomains(&[_]libvirt.Domain.Flags{
|
||||
// libvirt.Domain.Flags.ListDomainsActive,
|
||||
// libvirt.Domain.Flags.ListDomainsInactive,
|
||||
// });
|
||||
// defer domain_iter.deinit();
|
||||
|
||||
// const connection = libvirt.c.virConnectOpenAuth("qemu+ssh://jeeves@evil.lan/system", libvirt.c.virConnectAuthPtrDefault, 0);
|
||||
// if (connection) |conn| {
|
||||
// const conn_uri = libvirt.c.virConnectGetURI(conn);
|
||||
// defer std.c.free(@ptrCast(conn_uri));
|
||||
// if (conn_uri) |uri| {
|
||||
// std.debug.print("conn uri: {s}\n", .{uri});
|
||||
// }
|
||||
|
||||
// const num_active_domains = libvirt.c.virConnectNumOfDomains(conn);
|
||||
// const num_inactive_domains = libvirt.c.virConnectNumOfDefinedDomains(conn);
|
||||
|
||||
// std.debug.print("there are {d} active and {d} inactive domains\n", .{ num_active_domains, num_inactive_domains });
|
||||
|
||||
// var domain_list: [*]libvirt.c.virDomainPtr = undefined;
|
||||
// const flags = libvirt.c.VIR_CONNECT_LIST_DOMAINS_ACTIVE | libvirt.c.VIR_CONNECT_LIST_DOMAINS_INACTIVE;
|
||||
// const num_domains = libvirt.c.virConnectListAllDomains(conn, @ptrCast(&domain_list), flags);
|
||||
|
||||
// var i: usize = 0;
|
||||
// while (i < num_domains) : (i += 1) {
|
||||
// const active = libvirt.c.virDomainIsActive(domain_list[i]);
|
||||
// const name = libvirt.c.virDomainGetName(domain_list[i]);
|
||||
// std.debug.print("name: {s}, active: {any}\n", .{ name, active });
|
||||
// _ = libvirt.c.virDomainFree(domain_list[i]);
|
||||
// }
|
||||
// while (domain_iter.next()) |domain| {
|
||||
// const active = domain.isActive();
|
||||
// const name = domain.getName();
|
||||
// std.debug.print("name: {s}, active: {any}\n", .{ name, active });
|
||||
// }
|
||||
|
||||
// var flake = try fs.cwd().createFile("flake.nix", .{});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue