nbos

nbos

https://git.tonybtw.com/nbos.git git://git.tonybtw.com/nbos.git
1,500 bytes raw
1
#ifndef NBOS_H
2
#define NBOS_H
3
4
#include <stddef.h>
5
#include <stdint.h>
6
7
#define NBOS_SCHEMA_VERSION 1
8
9
typedef struct {
10
    const char *const *data;
11
    size_t             len;
12
} strs;
13
14
typedef struct pkg pkg;
15
16
typedef struct {
17
    const pkg *const *data;
18
    size_t            len;
19
} pkg_refs;
20
21
typedef enum : uint8_t {
22
    BUILD_AUTOTOOLS = 1,
23
    BUILD_CMAKE     = 2,
24
    BUILD_MESON     = 3,
25
    BUILD_MAKE      = 4,
26
    BUILD_CARGO     = 5,
27
    BUILD_GO        = 6,
28
    BUILD_ZIG       = 7,
29
    BUILD_SHELL     = 99,
30
} build_system;
31
32
struct pkg {
33
    const char  *name;
34
    const char  *version;
35
    const char  *src;
36
    const char  *sha256;
37
    pkg_refs     deps;
38
    const char  *build_flags;
39
    build_system build_sys;
40
};
41
42
typedef struct {
43
    const char *name;
44
    bool        enabled;
45
    strs        after;
46
} service;
47
48
typedef struct {
49
    const service *data;
50
    size_t         len;
51
} services;
52
53
typedef struct {
54
    const char *name;
55
    const pkg  *shell;
56
    const char *home;
57
    strs        groups;
58
} user;
59
60
typedef struct {
61
    const user *data;
62
    size_t      len;
63
} users;
64
65
typedef struct {
66
    const char *bootloader;
67
    const pkg  *kernel;
68
    const char *kernel_params;
69
} boot_cfg;
70
71
typedef struct {
72
    uint32_t    schema_version;
73
    const char *hostname;
74
    boot_cfg    boot;
75
    pkg_refs    pkgs;
76
    services    services;
77
    users       users;
78
} system_cfg;
79
80
#define SYSTEM_CFG_INIT(...) { \
81
    .schema_version = NBOS_SCHEMA_VERSION, \
82
    __VA_ARGS__ \
83
}
84
85
#endif