types.zig

2.1 KB · raw

1const std = @import("std");23pub const NixPackage = struct {4    attr: []const u8,5    pname: []const u8,6    version: []const u8,7    description: []const u8,8};910pub const Machine = struct {11    name: []const u8 = "local",12    config_path: []const u8 = "/etc/nixos",13    local: bool = true,14    default: bool = false,15    host: ?[]const u8 = null,16    user: ?[]const u8 = null,17    ssh_key: ?[]const u8 = null,18};1920pub const NinaConfig = struct {21    editor: []const u8 = "vim",22    generations: u32 = 5,23    confirm: bool = true,24    teach: bool = false,25    color: bool = true,26    // Flake-based system (vs nixos channels). Channel commands warn when set.27    flake: bool = false,28    machines: []Machine = &.{},29};3031pub const GenerationInfo = struct {32    number: u32,33    date: []const u8,34    time: []const u8,35    current: bool,36};3738pub const ServiceInfo = struct {39    name: []const u8,40    state: ServiceState,41    uptime: ?[]const u8 = null,42};4344pub const ServiceState = enum { active, failed, inactive, unknown };4546pub const ChannelInfo = struct {47    name: []const u8,48    url: []const u8,49};5051pub const DiffEntry = struct {52    op: DiffOp,53    package: []const u8,54    old_version: ?[]const u8 = null,55    new_version: ?[]const u8 = null,56};5758pub const DiffOp = enum { add, remove, change };5960pub const FlakeInput = struct {61    name: []const u8,62    old_rev: ?[]const u8 = null,63    new_rev: ?[]const u8 = null,64    changed: bool = false,65};6667pub const StoreInfo = struct {68    total_size: []const u8,69    live_paths: u64,70    reclaimable_paths: u64,71};7273pub const BootEntry = struct {74    title: []const u8,75    date: ?[]const u8 = null,76    current: bool = false,77};7879pub const DoctorCheck = struct {80    name: []const u8,81    status: DoctorStatus,82    note: ?[]const u8 = null,83};8485pub const DoctorStatus = enum { ok, warn, fail };8687pub const InstallPath = enum { profile, system };8889test "types are defined" {90    const p = NixPackage{91        .attr = "firefox",92        .pname = "firefox",93        .version = "124.0",94        .description = "A browser",95    };96    try std.testing.expectEqualStrings("firefox", p.attr);97}