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    machines: []Machine = &.{},27};2829pub const GenerationInfo = struct {30    number: u32,31    date: []const u8,32    time: []const u8,33    current: bool,34};3536pub const ServiceInfo = struct {37    name: []const u8,38    state: ServiceState,39    uptime: ?[]const u8 = null,40};4142pub const ServiceState = enum { active, failed, inactive, unknown };4344pub const ChannelInfo = struct {45    name: []const u8,46    url: []const u8,47};4849pub const DiffEntry = struct {50    op: DiffOp,51    package: []const u8,52    old_version: ?[]const u8 = null,53    new_version: ?[]const u8 = null,54};5556pub const DiffOp = enum { add, remove, change };5758pub const FlakeInput = struct {59    name: []const u8,60    old_rev: ?[]const u8 = null,61    new_rev: ?[]const u8 = null,62    changed: bool = false,63};6465pub const StoreInfo = struct {66    total_size: []const u8,67    live_paths: u64,68    reclaimable_paths: u64,69};7071pub const BootEntry = struct {72    title: []const u8,73    date: ?[]const u8 = null,74    current: bool = false,75};7677pub const DoctorCheck = struct {78    name: []const u8,79    status: DoctorStatus,80    note: ?[]const u8 = null,81};8283pub const DoctorStatus = enum { ok, warn, fail };8485pub const InstallPath = enum { profile, system };8687pub const SearchResult = struct {88    package: NixPackage,89    action: InstallPath,90};9192test "types are defined" {93    const p = NixPackage{94        .attr = "firefox",95        .pname = "firefox",96        .version = "124.0",97        .description = "A browser",98    };99    try std.testing.expectEqualStrings("firefox", p.attr);100}