types.zig

2.3 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    // true when the search required NIXPKGS_ALLOW_UNFREE=1 to return this package.9    // The install step uses this to pass the same env so the profile add succeeds.10    unfree: bool = false,11};1213pub const Machine = struct {14    name: []const u8 = "local",15    config_path: []const u8 = "/etc/nixos",16    local: bool = true,17    default: bool = false,18    host: ?[]const u8 = null,19    user: ?[]const u8 = null,20    ssh_key: ?[]const u8 = null,21};2223pub const NinaConfig = struct {24    editor: []const u8 = "vim",25    generations: u32 = 5,26    confirm: bool = true,27    teach: bool = false,28    color: bool = true,29    // Flake-based system (vs nixos channels). Channel commands warn when set.30    flake: bool = false,31    machines: []Machine = &.{},32};3334pub const GenerationInfo = struct {35    number: u32,36    date: []const u8,37    time: []const u8,38    current: bool,39};4041pub const ServiceInfo = struct {42    name: []const u8,43    state: ServiceState,44    uptime: ?[]const u8 = null,45};4647pub const ServiceState = enum { active, failed, inactive, unknown };4849pub const ChannelInfo = struct {50    name: []const u8,51    url: []const u8,52};5354pub const DiffEntry = struct {55    op: DiffOp,56    package: []const u8,57    old_version: ?[]const u8 = null,58    new_version: ?[]const u8 = null,59};6061pub const DiffOp = enum { add, remove, change };6263pub const FlakeInput = struct {64    name: []const u8,65    old_rev: ?[]const u8 = null,66    new_rev: ?[]const u8 = null,67    changed: bool = false,68};6970pub const StoreInfo = struct {71    total_size: []const u8,72    live_paths: u64,73    reclaimable_paths: u64,74};7576pub const BootEntry = struct {77    title: []const u8,78    date: ?[]const u8 = null,79    current: bool = false,80};8182pub const DoctorCheck = struct {83    name: []const u8,84    status: DoctorStatus,85    note: ?[]const u8 = null,86};8788pub const DoctorStatus = enum { ok, warn, fail };8990pub const InstallPath = enum { profile, system };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}