@highstate/library 0.9.16 → 0.9.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/dist/highstate.library.msgpack +0 -0
  2. package/dist/index.js +3548 -2985
  3. package/dist/index.js.map +1 -1
  4. package/package.json +5 -5
  5. package/src/common/access-point.ts +105 -0
  6. package/src/common/files.ts +137 -0
  7. package/src/common/index.ts +3 -0
  8. package/src/common/server.ts +231 -0
  9. package/src/databases/index.ts +4 -0
  10. package/src/databases/mariadb.ts +37 -0
  11. package/src/databases/mongodb.ts +37 -0
  12. package/src/databases/postgresql.ts +37 -0
  13. package/src/databases/shared.ts +61 -0
  14. package/src/distributions/ubuntu.ts +13 -11
  15. package/src/dns.ts +116 -18
  16. package/src/git.ts +14 -10
  17. package/src/impl-ref.ts +26 -0
  18. package/src/index.ts +14 -15
  19. package/src/k3s.ts +14 -12
  20. package/src/k8s/apps/code-server.ts +48 -0
  21. package/src/k8s/apps/gitea.ts +25 -0
  22. package/src/k8s/apps/grocy.ts +39 -0
  23. package/src/k8s/apps/hubble.ts +30 -0
  24. package/src/{apps → k8s/apps}/index.ts +16 -13
  25. package/src/k8s/apps/kubernetes-dashboard.ts +28 -0
  26. package/src/k8s/apps/mariadb.ts +83 -0
  27. package/src/k8s/apps/maybe.ts +39 -0
  28. package/src/k8s/apps/mongodb.ts +84 -0
  29. package/src/k8s/apps/postgresql.ts +86 -0
  30. package/src/k8s/apps/shared.ts +149 -0
  31. package/src/k8s/apps/syncthing.ts +72 -0
  32. package/src/k8s/apps/traefik.ts +40 -0
  33. package/src/k8s/apps/vaultwarden.ts +31 -0
  34. package/src/k8s/apps/workload.ts +214 -0
  35. package/src/k8s/apps/zitadel.ts +26 -0
  36. package/src/k8s/cert-manager.ts +80 -0
  37. package/src/k8s/cilium.ts +64 -0
  38. package/src/k8s/gateway.ts +70 -0
  39. package/src/k8s/index.ts +9 -0
  40. package/src/{obfuscators → k8s/obfuscators}/phantun.ts +14 -10
  41. package/src/{obfuscators → k8s/obfuscators}/shared.ts +17 -11
  42. package/src/k8s/resources.ts +111 -0
  43. package/src/k8s/service.ts +65 -0
  44. package/src/k8s/shared.ts +343 -0
  45. package/src/k8s/workload.ts +77 -0
  46. package/src/network.ts +249 -63
  47. package/src/nixos.ts +38 -77
  48. package/src/proxmox.ts +203 -96
  49. package/src/restic.ts +28 -19
  50. package/src/sops.ts +19 -8
  51. package/src/ssh.ts +122 -24
  52. package/src/talos.ts +21 -19
  53. package/src/third-party/cloudflare.ts +59 -0
  54. package/src/third-party/index.ts +3 -0
  55. package/src/{mullvad.ts → third-party/mullvad.ts} +11 -9
  56. package/src/third-party/timeweb.ts +99 -0
  57. package/src/utils.ts +27 -6
  58. package/src/wireguard.ts +249 -115
  59. package/src/apps/code-server.ts +0 -34
  60. package/src/apps/deployment.ts +0 -60
  61. package/src/apps/dns.ts +0 -107
  62. package/src/apps/gitea.ts +0 -18
  63. package/src/apps/grocy.ts +0 -20
  64. package/src/apps/hubble.ts +0 -20
  65. package/src/apps/kubernetes-dashboard.ts +0 -19
  66. package/src/apps/mariadb.ts +0 -81
  67. package/src/apps/maybe.ts +0 -25
  68. package/src/apps/mongodb.ts +0 -81
  69. package/src/apps/network.ts +0 -55
  70. package/src/apps/postgresql.ts +0 -81
  71. package/src/apps/shared.ts +0 -290
  72. package/src/apps/syncthing.ts +0 -54
  73. package/src/apps/test.ts +0 -19
  74. package/src/apps/traefik.ts +0 -36
  75. package/src/apps/vaultwarden.ts +0 -23
  76. package/src/apps/zitadel.ts +0 -21
  77. package/src/cloudflare.ts +0 -26
  78. package/src/common.ts +0 -200
  79. package/src/files.ts +0 -146
  80. package/src/k8s.ts +0 -638
  81. package/src/timeweb.ts +0 -75
  82. package/src/{obfuscators → k8s/obfuscators}/index.ts +1 -1
package/src/network.ts CHANGED
@@ -1,78 +1,115 @@
1
- import { defineEntity, defineUnit, Type, type Static } from "@highstate/contract"
1
+ import type { Simplify } from "type-fest"
2
+ import { defineEntity, defineUnit, z } from "@highstate/contract"
2
3
 
3
- export const endpointVisibilitySchema = Type.StringEnum([
4
- "public", // Reachable from the public internet
5
- "external", // Reachable from outside the system boundary, but not public
6
- "internal", // Reachable only from within the system or cluster
4
+ export const endpointVisibilitySchema = z.enum([
5
+ "public", // reachable from the public internet
6
+ "external", // reachable from outside the system boundary, but not public
7
+ "internal", // reachable only from within the system or cluster
7
8
  ])
8
9
 
9
- export const endpointFilterSchema = Type.Array(endpointVisibilitySchema)
10
+ export const endpointFilterSchema = endpointVisibilitySchema.array()
10
11
 
12
+ /**
13
+ * The L3 endpoint for some service.
14
+ *
15
+ * May be a domain name or an IP address.
16
+ */
11
17
  export const l3EndpointEntity = defineEntity({
12
- type: "network.l3-endpoint",
13
-
14
- schema: Type.Intersect([
15
- Type.Object({
18
+ type: "network.l3-endpoint.v1",
19
+
20
+ schema: z.intersection(
21
+ z.object({
22
+ /**
23
+ * The generic visibility of an endpoint.
24
+ *
25
+ * - `public`: reachable from the public internet;
26
+ * - `external`: reachable from outside the system boundary (e.g., LAN, VPC), but not public;
27
+ * - `internal`: reachable only from within the application or infrastructure boundary (e.g., within a cluster).
28
+ */
16
29
  visibility: endpointVisibilitySchema,
17
- metadata: Type.Optional(Type.Record(Type.String(), Type.Unknown())),
30
+
31
+ /**
32
+ * The extra metadata for the endpoint.
33
+ *
34
+ * In most cases, this is provided by the endpoint origin (e.g., a Kubernetes service).
35
+ */
36
+ metadata: z.record(z.string(), z.unknown()).optional(),
18
37
  }),
19
- Type.Union([
20
- Type.Object({
21
- type: Type.Literal("hostname"),
38
+ z.union([
39
+ z.object({
40
+ type: z.literal("hostname"),
22
41
 
23
42
  /**
24
43
  * The hostname of the endpoint in the format of a domain name.
25
44
  */
26
- hostname: Type.String(),
45
+ hostname: z.string(),
27
46
  }),
28
- Type.Object({
29
- type: Type.Literal("ipv4"),
47
+ z.object({
48
+ type: z.literal("ipv4"),
30
49
 
31
50
  /**
32
51
  * The IPv4 address of the endpoint.
33
52
  */
34
- address: Type.String(),
53
+ address: z.string(),
35
54
  }),
36
- Type.Object({
37
- type: Type.Literal("ipv6"),
55
+ z.object({
56
+ type: z.literal("ipv6"),
38
57
 
39
58
  /**
40
59
  * The IPv6 address of the endpoint.
41
60
  */
42
- address: Type.String(),
61
+ address: z.string(),
43
62
  }),
44
63
  ]),
45
- ]),
64
+ ),
46
65
 
47
66
  meta: {
48
67
  color: "#4CAF50",
49
- description: "The L3 endpoint for some service. May be a domain name or an IP address.",
50
68
  },
51
69
  })
52
70
 
53
- export const l4ProtocolSchema = Type.StringEnum(["tcp", "udp"])
71
+ export const l4ProtocolSchema = z.enum(["tcp", "udp"])
72
+
73
+ /**
74
+ * The schema for a TCP/UDP port.
75
+ */
76
+ export const portSchema = z.number().int().min(1).max(65535)
77
+
78
+ /**
79
+ * The schema for an IPv4 prefix length.
80
+ */
81
+ export const ipv4PrefixSchema = z.number().int().min(0).max(32)
54
82
 
55
- export const l4PortInfoSchema = Type.Object({
56
- port: Type.Number(),
83
+ /**
84
+ * The schema for address that can be either IPv4 or IPv6.
85
+ */
86
+ export const ipv46Schema = z.union([z.ipv4(), z.ipv6()])
87
+
88
+ export const l4PortInfoSchema = z.object({
89
+ port: portSchema,
57
90
  protocol: l4ProtocolSchema,
58
91
  })
59
92
 
93
+ /**
94
+ * The L4 endpoint for some service.
95
+ *
96
+ * Extends an L3 endpoint with a port and protocol.
97
+ */
60
98
  export const l4EndpointEntity = defineEntity({
61
- type: "network.l4-endpoint",
99
+ type: "network.l4-endpoint.v1",
62
100
 
63
- schema: Type.Intersect([l3EndpointEntity.schema, l4PortInfoSchema]),
101
+ schema: z.intersection(l3EndpointEntity.schema, l4PortInfoSchema),
64
102
 
65
103
  meta: {
66
104
  color: "#2196F3",
67
- description: "The L4 endpoint for some service. Extends an L3 endpoint with a port.",
68
105
  },
69
106
  })
70
107
 
71
- export const l7AppInfoSchema = Type.Object({
108
+ export const l7AppInfoSchema = z.object({
72
109
  /**
73
110
  * The name of the application protocol used by the endpoint.
74
111
  */
75
- appProtocol: Type.String(),
112
+ appProtocol: z.string(),
76
113
 
77
114
  /**
78
115
  * The resource path of the application endpoint, including query parameters.
@@ -80,23 +117,29 @@ export const l7AppInfoSchema = Type.Object({
80
117
  *
81
118
  * Example: `api/v1/resource?query=value`, `database?param=value`, `user/repo.git`.
82
119
  */
83
- resource: Type.Optional(Type.String()),
120
+ resource: z.string().optional(),
84
121
  })
85
122
 
123
+ /**
124
+ * The L7 endpoint for some service.
125
+ *
126
+ * Extends an L4 endpoint with application protocol information.
127
+ */
86
128
  export const l7EndpointEntity = defineEntity({
87
- type: "network.l7-endpoint",
129
+ type: "network.l7-endpoint.v1",
88
130
 
89
- schema: Type.Intersect([l4EndpointEntity.schema, l7AppInfoSchema]),
131
+ schema: z.intersection(l4EndpointEntity.schema, l7AppInfoSchema),
90
132
 
91
133
  meta: {
92
134
  color: "#FF9800",
93
- description:
94
- "The L7 endpoint for some service. Extends an L4 endpoint with application protocol information.",
95
135
  },
96
136
  })
97
137
 
138
+ /**
139
+ * The component which creates an L3 endpoint.
140
+ */
98
141
  export const l3Endpoint = defineUnit({
99
- type: "network.l3-endpoint",
142
+ type: "network.l3-endpoint.v1",
100
143
 
101
144
  args: {
102
145
  /**
@@ -104,12 +147,19 @@ export const l3Endpoint = defineUnit({
104
147
  *
105
148
  * May be a domain name or an IP address.
106
149
  */
107
- endpoint: Type.String(),
150
+ endpoint: z.string(),
108
151
 
109
152
  /**
110
153
  * The visibility of the endpoint.
154
+ *
155
+ * The visibility levels are:
156
+ * - `public`: reachable from the public internet;
157
+ * - `external`: reachable from outside the system boundary (e.g., LAN, VPC), but not public;
158
+ * - `internal`: reachable only from within the application or infrastructure boundary (e.g., within a cluster).
159
+ *
160
+ * If not specified, defaults to `public`.
111
161
  */
112
- visibility: Type.Default(endpointVisibilitySchema, "public"),
162
+ visibility: endpointVisibilitySchema.default("public"),
113
163
  },
114
164
 
115
165
  outputs: {
@@ -117,10 +167,9 @@ export const l3Endpoint = defineUnit({
117
167
  },
118
168
 
119
169
  meta: {
120
- displayName: "L3 Endpoint",
121
- description: "An L3 endpoint for some service. May be a domain name or an IP address.",
122
- primaryIcon: "mdi:network-outline",
123
- primaryIconColor: "#4CAF50",
170
+ title: "L3 Endpoint",
171
+ icon: "mdi:network-outline",
172
+ iconColor: "#4CAF50",
124
173
  defaultNamePrefix: "endpoint",
125
174
  category: "Network",
126
175
  },
@@ -131,8 +180,11 @@ export const l3Endpoint = defineUnit({
131
180
  },
132
181
  })
133
182
 
183
+ /**
184
+ * The component which creates an L4 endpoint.
185
+ */
134
186
  export const l4Endpoint = defineUnit({
135
- type: "network.l4-endpoint",
187
+ type: "network.l4-endpoint.v1",
136
188
 
137
189
  args: {
138
190
  /**
@@ -146,12 +198,19 @@ export const l4Endpoint = defineUnit({
146
198
  * - `tcp://endpoint:port`
147
199
  * - `udp://endpoint:port`
148
200
  */
149
- endpoint: Type.String(),
201
+ endpoint: z.string(),
150
202
 
151
203
  /**
152
204
  * The visibility of the endpoint.
205
+ *
206
+ * The visibility levels are:
207
+ * - `public`: reachable from the public internet;
208
+ * - `external`: reachable from outside the system boundary (e.g., LAN, VPC), but not public;
209
+ * - `internal`: reachable only from within the application or infrastructure boundary (e.g., within a cluster).
210
+ *
211
+ * If not specified, defaults to `public`.
153
212
  */
154
- visibility: Type.Default(endpointVisibilitySchema, "public"),
213
+ visibility: endpointVisibilitySchema.default("public"),
155
214
  },
156
215
 
157
216
  outputs: {
@@ -159,10 +218,9 @@ export const l4Endpoint = defineUnit({
159
218
  },
160
219
 
161
220
  meta: {
162
- displayName: "L4 Endpoint",
163
- description: "An L4 endpoint for some service. Extends an L3 endpoint with a port.",
164
- primaryIcon: "mdi:network-outline",
165
- primaryIconColor: "#2196F3",
221
+ title: "L4 Endpoint",
222
+ icon: "mdi:network-outline",
223
+ iconColor: "#2196F3",
166
224
  defaultNamePrefix: "endpoint",
167
225
  category: "Network",
168
226
  },
@@ -173,14 +231,128 @@ export const l4Endpoint = defineUnit({
173
231
  },
174
232
  })
175
233
 
234
+ /**
235
+ * The component which creates an L7 endpoint.
236
+ */
237
+ export const l7Endpoint = defineUnit({
238
+ type: "network.l7-endpoint.v1",
239
+
240
+ args: {
241
+ /**
242
+ * The string representation of the endpoint.
243
+ *
244
+ * The possible formats are:
245
+ *
246
+ * - `https://endpoint:port/resource`
247
+ * - `ftp://endpoint:port/resource`
248
+ * - `someotherprotocol://endpoint:port/resource`
249
+ */
250
+ endpoint: z.string(),
251
+
252
+ /**
253
+ * The visibility of the endpoint.
254
+ *
255
+ * The visibility levels are:
256
+ * - `public`: reachable from the public internet;
257
+ * - `external`: reachable from outside the system boundary (e.g., LAN, VPC), but not public;
258
+ * - `internal`: reachable only from within the application or infrastructure boundary (e.g., within a cluster).
259
+ *
260
+ * If not specified, defaults to `public`.
261
+ */
262
+ visibility: endpointVisibilitySchema.default("public"),
263
+ },
264
+
265
+ outputs: {
266
+ endpoint: l7EndpointEntity,
267
+ },
268
+
269
+ meta: {
270
+ title: "L7 Endpoint",
271
+ icon: "mdi:network-outline",
272
+ iconColor: "#FF9800",
273
+ defaultNamePrefix: "endpoint",
274
+ category: "Network",
275
+ },
276
+
277
+ source: {
278
+ package: "@highstate/common",
279
+ path: "units/network/l7-endpoint",
280
+ },
281
+ })
282
+
283
+ /**
284
+ * Explicitly filter endpoints by their accessibility.
285
+ */
286
+ export const endpointFilter = defineUnit({
287
+ type: "network.endpoint-filter.v1",
288
+
289
+ args: {
290
+ /**
291
+ * The endpoint filter to filter the endpoints before creating the DNS records.
292
+ *
293
+ * Possible values:
294
+ *
295
+ * - `public`: only endpoints exposed to the public internet;
296
+ * - `external`: reachable from outside the system but not public (e.g., LAN, VPC);
297
+ * - `internal`: reachable only from within the system boundary (e.g., inside a cluster).
298
+ *
299
+ * You can select one or more values.
300
+ *
301
+ * If no value is provided, the endpoints will be filtered by the most accessible type:
302
+ *
303
+ * - if any public endpoints exist, all public endpoints are selected;
304
+ * - otherwise, if any external endpoints exist, all external endpoints are selected;
305
+ * - if neither exist, all internal endpoints are selected.
306
+ */
307
+ endpointFilter: endpointFilterSchema.default([]),
308
+ },
309
+
310
+ inputs: {
311
+ l3Endpoints: {
312
+ entity: l3EndpointEntity,
313
+ multiple: true,
314
+ required: false,
315
+ },
316
+ l4Endpoints: {
317
+ entity: l4EndpointEntity,
318
+ multiple: true,
319
+ required: false,
320
+ },
321
+ },
322
+
323
+ outputs: {
324
+ l3Endpoints: {
325
+ entity: l3EndpointEntity,
326
+ multiple: true,
327
+ },
328
+ l4Endpoints: {
329
+ entity: l4EndpointEntity,
330
+ multiple: true,
331
+ },
332
+ },
333
+
334
+ meta: {
335
+ title: "Endpoint Filter",
336
+ icon: "mdi:network-outline",
337
+ iconColor: "#FF9800",
338
+ secondaryIcon: "mdi:filter-outline",
339
+ category: "Network",
340
+ },
341
+
342
+ source: {
343
+ package: "@highstate/common",
344
+ path: "units/network/endpoint-filter",
345
+ },
346
+ })
347
+
176
348
  /**
177
349
  * The generic visibility of an endpoint.
178
350
  *
179
- * - `public`: Reachable from the public internet.
180
- * - `external`: Reachable from outside the system boundary (e.g., LAN, VPC), but not public.
181
- * - `internal`: Reachable only from within the application or infrastructure boundary (e.g., within a cluster).
351
+ * - `public`: reachable from the public internet;
352
+ * - `external`: reachable from outside the system boundary (e.g., LAN, VPC), but not public;
353
+ * - `internal`: reachable only from within the application or infrastructure boundary (e.g., within a cluster).
182
354
  */
183
- export type EndpointVisibility = Static<typeof endpointVisibilitySchema>
355
+ export type EndpointVisibility = z.infer<typeof endpointVisibilitySchema>
184
356
 
185
357
  /**
186
358
  * The list of endpoint visibility levels used to filter endpoints.
@@ -190,16 +362,30 @@ export type EndpointVisibility = Static<typeof endpointVisibilitySchema>
190
362
  * - Otherwise, if any external endpoints exist, all external endpoints are selected.
191
363
  * - If neither exist, all internal endpoints are selected.
192
364
  */
193
- export type EndpointFilter = Static<typeof endpointFilterSchema>
194
-
195
- export type L3Endpoint = Static<typeof l3EndpointEntity.schema>
196
- export type L4Endpoint = Static<typeof l4EndpointEntity.schema>
197
- export type L4Protocol = Static<typeof l4ProtocolSchema>
198
- export type L4PortInfo = Static<typeof l4PortInfoSchema>
199
- export type L7Endpoint = Static<typeof l7EndpointEntity.schema>
200
- export type L7AppInfo = Static<typeof l7AppInfoSchema>
365
+ export type EndpointFilter = z.infer<typeof endpointFilterSchema>
366
+
367
+ export type L3Endpoint = Simplify<z.infer<typeof l3EndpointEntity.schema>>
368
+ export type L4Endpoint = Simplify<z.infer<typeof l4EndpointEntity.schema>>
369
+ export type L4Protocol = z.infer<typeof l4ProtocolSchema>
370
+ export type L4PortInfo = z.infer<typeof l4PortInfoSchema>
371
+ export type L7Endpoint = Simplify<z.infer<typeof l7EndpointEntity.schema>>
372
+ export type L7AppInfo = z.infer<typeof l7AppInfoSchema>
373
+
374
+ export const l34EndpointSchema = z.union([
375
+ z.intersection(
376
+ l3EndpointEntity.schema,
377
+ z.object({
378
+ port: z.undefined().optional(),
379
+ protocol: z.undefined().optional(),
380
+ }),
381
+ ),
382
+ l4EndpointEntity.schema,
383
+ ])
201
384
 
202
385
  /**
203
386
  * The L3 or L4 endpoint for some service.
387
+ *
388
+ * For convenience, L3 case have `port` and `protocol` fields as `undefined`,
389
+ * so you can check any of them to determine if it's an L3 or L4 endpoint.
204
390
  */
205
- export type L34Endpoint = (L3Endpoint & { port?: undefined; protocol?: undefined }) | L4Endpoint
391
+ export type L34Endpoint = Simplify<z.infer<typeof l34EndpointSchema>>
package/src/nixos.ts CHANGED
@@ -1,35 +1,12 @@
1
- import { defineUnit, Type } from "@highstate/contract"
2
- import { fileEntity, folderEntity } from "./files"
3
- import { serverEntity } from "./common"
4
-
5
- // export const moduleEntity = defineEntity({
6
- // type: "nixos.module",
7
-
8
- // schema: Type.Object({
9
- // /**
10
- // * The folder containing the NixOS module files.
11
- // *
12
- // * @schema
13
- // */
14
- // folder: folderEntity.schema,
15
-
16
- // /**
17
- // * The name of the module file entrypoint to use when importing this module.
18
- // *
19
- // * @schema
20
- // */
21
- // entrypoint: Type.String(),
22
- // }),
23
-
24
- // meta: {
25
- // displayName: "NixOS Module",
26
- // description: "The NixOS module reference.",
27
- // color: "#5277c3",
28
- // },
29
- // })
1
+ import { defineUnit, z } from "@highstate/contract"
2
+ import { fileEntity, folderEntity } from "./common/files"
3
+ import { serverEntity } from "./common/server"
30
4
 
5
+ /**
6
+ * Creates a NixOS module from inline code.
7
+ */
31
8
  export const inlineModule = defineUnit({
32
- type: "nixos.inline-module",
9
+ type: "nixos.inline-module.v1",
33
10
 
34
11
  args: {
35
12
  /**
@@ -37,14 +14,14 @@ export const inlineModule = defineUnit({
37
14
  *
38
15
  * If not provided, the name will be the name of the unit.
39
16
  */
40
- moduleName: Type.Optional(Type.String()),
17
+ moduleName: z.string().optional(),
41
18
 
42
19
  /**
43
20
  * The code of the NixOS module.
44
21
  *
45
22
  * In this code you can reference other modules and files by their names.
46
23
  */
47
- code: Type.String({ language: "nix" }),
24
+ code: z.string().meta({ language: "nix" }),
48
25
  },
49
26
 
50
27
  inputs: {
@@ -65,10 +42,9 @@ export const inlineModule = defineUnit({
65
42
  },
66
43
 
67
44
  meta: {
68
- displayName: "NixOS Inline Module",
69
- description: "Creates a NixOS module from inline code.",
70
- primaryIcon: "simple-icons:nixos",
71
- primaryIconColor: "#7ebae4",
45
+ title: "NixOS Inline Module",
46
+ icon: "simple-icons:nixos",
47
+ iconColor: "#7ebae4",
72
48
  secondaryIcon: "mdi:file-code",
73
49
  category: "NixOS",
74
50
  },
@@ -79,36 +55,14 @@ export const inlineModule = defineUnit({
79
55
  },
80
56
  })
81
57
 
82
- // export const flakeEntity = defineEntity({
83
- // type: "nixos.flake",
84
-
85
- // schema: Type.Object({
86
- // /**
87
- // * The git repository where the flake is stored.
88
- // *
89
- // * @schema
90
- // */
91
- // repository: repositoryEntity.schema,
92
-
93
- // /**
94
- // * The relative path to the folder containing the flake.nix file.
95
- // *
96
- // * If not provided, the root of the repository will be used.
97
- // *
98
- // * @schema
99
- // */
100
- // flakePath: Type.Optional(Type.String()),
101
- // }),
102
-
103
- // meta: {
104
- // displayName: "NixOS Flake",
105
- // description: "The NixOS flake reference.",
106
- // color: "#5277c3",
107
- // },
108
- // })
109
-
58
+ /**
59
+ * Creates a NixOS flake from inline code.
60
+ *
61
+ * This unit allows you to define a NixOS flake directly in the unit code.
62
+ * It can reference other flakes, modules, files, and folders by their names.
63
+ */
110
64
  export const inlineFlake = defineUnit({
111
- type: "nixos.inline-flake",
65
+ type: "nixos.inline-flake.v1",
112
66
 
113
67
  args: {
114
68
  /**
@@ -116,14 +70,14 @@ export const inlineFlake = defineUnit({
116
70
  *
117
71
  * If not provided, the name will be the name of the unit.
118
72
  */
119
- flakeName: Type.Optional(Type.String()),
73
+ flakeName: z.string().optional(),
120
74
 
121
75
  /**
122
76
  * The code of the `flake.nix` file.
123
77
  *
124
78
  * In this code you can reference other flakes, modules, files, and folders by their names.
125
79
  */
126
- code: Type.String({ language: "nix" }),
80
+ code: z.string().meta({ language: "nix" }),
127
81
  },
128
82
 
129
83
  inputs: {
@@ -144,10 +98,9 @@ export const inlineFlake = defineUnit({
144
98
  },
145
99
 
146
100
  meta: {
147
- displayName: "NixOS Inline Flake",
148
- description: "Creates a NixOS flake from inline code.",
149
- primaryIcon: "simple-icons:nixos",
150
- primaryIconColor: "#7ebae4",
101
+ title: "NixOS Inline Flake",
102
+ icon: "simple-icons:nixos",
103
+ iconColor: "#7ebae4",
151
104
  secondaryIcon: "mdi:file-code",
152
105
  category: "NixOS",
153
106
  },
@@ -158,11 +111,20 @@ export const inlineFlake = defineUnit({
158
111
  },
159
112
  })
160
113
 
114
+ /**
115
+ * Creates a NixOS system on top of any server.
116
+ *
117
+ * This unit allows you to define a NixOS system configuration that will be applied to the server.
118
+ * It can reference other modules, files, and folders by their names.
119
+ *
120
+ * To create a NixOS system, it will use `nixos-anywhere` which will use kexec
121
+ * to boot into the new kernel to install NixOS.
122
+ */
161
123
  export const system = defineUnit({
162
- type: "nixos.system",
124
+ type: "nixos.system.v1",
163
125
 
164
126
  args: {
165
- system: Type.Optional(Type.String()),
127
+ system: z.string().optional(),
166
128
  },
167
129
 
168
130
  inputs: {
@@ -175,10 +137,9 @@ export const system = defineUnit({
175
137
  },
176
138
 
177
139
  meta: {
178
- displayName: "NixOS System",
179
- description: "Creates a NixOS system on top of any server.",
180
- primaryIcon: "simple-icons:nixos",
181
- primaryIconColor: "#7ebae4",
140
+ title: "NixOS System",
141
+ icon: "simple-icons:nixos",
142
+ iconColor: "#7ebae4",
182
143
  secondaryIcon: "codicon:vm",
183
144
  category: "NixOS",
184
145
  },